Admin app login form should use swapped user model
This commit is contained in:
parent
7e82e83d67
commit
d088b3af58
|
@ -4,7 +4,7 @@ from django import forms
|
||||||
|
|
||||||
from django.contrib.auth import authenticate
|
from django.contrib.auth import authenticate
|
||||||
from django.contrib.auth.forms import AuthenticationForm
|
from django.contrib.auth.forms import AuthenticationForm
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth import get_user_model
|
||||||
from django.utils.translation import ugettext_lazy, ugettext as _
|
from django.utils.translation import ugettext_lazy, ugettext as _
|
||||||
|
|
||||||
ERROR_MESSAGE = ugettext_lazy("Please enter the correct username and password "
|
ERROR_MESSAGE = ugettext_lazy("Please enter the correct username and password "
|
||||||
|
@ -29,9 +29,10 @@ class AdminAuthenticationForm(AuthenticationForm):
|
||||||
if self.user_cache is None:
|
if self.user_cache is None:
|
||||||
if '@' in username:
|
if '@' in username:
|
||||||
# Mistakenly entered e-mail address instead of username? Look it up.
|
# Mistakenly entered e-mail address instead of username? Look it up.
|
||||||
|
user_model = get_user_model()
|
||||||
try:
|
try:
|
||||||
user = User.objects.get(email=username)
|
user = user_model.objects.get(email=username)
|
||||||
except (User.DoesNotExist, User.MultipleObjectsReturned):
|
except (user_model.DoesNotExist, user_model.MultipleObjectsReturned):
|
||||||
# Nothing to do here, moving along.
|
# Nothing to do here, moving along.
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue