From b68fac7e88c08cd0bb3dde86388292ddc863eba5 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Mon, 19 May 2014 08:35:44 -0400 Subject: [PATCH] Fixed #22652 -- Replaced UserModel.objects with UserModel._default_manager. Thanks alexdlaird for the report. --- django/contrib/auth/backends.py | 4 ++-- django/contrib/auth/management/__init__.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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): ")