diff --git a/django/contrib/auth/backends.py b/django/contrib/auth/backends.py index a39a701888..7d452971ee 100644 --- a/django/contrib/auth/backends.py +++ b/django/contrib/auth/backends.py @@ -106,14 +106,14 @@ class RemoteUserBackend(ModelBackend): # instead we use get_or_create when creating unknown users since it has # built-in safeguards for multiple threads. if self.create_unknown_user: - user, created = UserModel.objects.get_or_create(**{ + user, created = UserModel._default_manager.get_or_create(**{ UserModel.USERNAME_FIELD: username }) if created: user = self.configure_user(user) else: try: - user = UserModel.objects.get_by_natural_key(username) + user = UserModel._default_manager.get_by_natural_key(username) except UserModel.DoesNotExist: pass return user diff --git a/django/contrib/auth/management/__init__.py b/django/contrib/auth/management/__init__.py index 029b4bb915..5e2a6b42e8 100644 --- a/django/contrib/auth/management/__init__.py +++ b/django/contrib/auth/management/__init__.py @@ -129,7 +129,7 @@ def create_superuser(app_config, verbosity=2, interactive=True, using=DEFAULT_DB from django.core.management import call_command - if not UserModel.objects.exists() and interactive: + if not UserModel._default_manager.exists() and interactive: msg = ("\nYou have installed Django's auth system, and " "don't have any superusers defined.\nWould you like to create one " "now? (yes/no): ")