Fixed #22652 -- Replaced UserModel.objects with UserModel._default_manager.
Thanks alexdlaird for the report.
This commit is contained in:
parent
5abc811a40
commit
b68fac7e88
|
@ -106,14 +106,14 @@ class RemoteUserBackend(ModelBackend):
|
||||||
# instead we use get_or_create when creating unknown users since it has
|
# instead we use get_or_create when creating unknown users since it has
|
||||||
# built-in safeguards for multiple threads.
|
# built-in safeguards for multiple threads.
|
||||||
if self.create_unknown_user:
|
if self.create_unknown_user:
|
||||||
user, created = UserModel.objects.get_or_create(**{
|
user, created = UserModel._default_manager.get_or_create(**{
|
||||||
UserModel.USERNAME_FIELD: username
|
UserModel.USERNAME_FIELD: username
|
||||||
})
|
})
|
||||||
if created:
|
if created:
|
||||||
user = self.configure_user(user)
|
user = self.configure_user(user)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
user = UserModel.objects.get_by_natural_key(username)
|
user = UserModel._default_manager.get_by_natural_key(username)
|
||||||
except UserModel.DoesNotExist:
|
except UserModel.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
return user
|
return user
|
||||||
|
|
|
@ -129,7 +129,7 @@ def create_superuser(app_config, verbosity=2, interactive=True, using=DEFAULT_DB
|
||||||
|
|
||||||
from django.core.management import call_command
|
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 "
|
msg = ("\nYou have installed Django's auth system, and "
|
||||||
"don't have any superusers defined.\nWould you like to create one "
|
"don't have any superusers defined.\nWould you like to create one "
|
||||||
"now? (yes/no): ")
|
"now? (yes/no): ")
|
||||||
|
|
Loading…
Reference in New Issue