Fix for #19944

See https://code.djangoproject.com/ticket/19944