Fixes #21439 Backport of 3560ef04 from master. Conflicts: django/contrib/auth/tests/test_auth_backends.py