Fixed #22652 -- Replaced UserModel.objects with UserModel._default_manager.

Thanks alexdlaird for the report.
This commit is contained in:
Tim Graham 2014-05-19 08:35:44 -04:00
parent 5abc811a40
commit b68fac7e88
2 changed files with 3 additions and 3 deletions

View File

@ -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

View File

@ -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): ")