From d088b3af58dad7449fc58493193a327725c57c22 Mon Sep 17 00:00:00 2001 From: Thomas Sutton Date: Mon, 20 Aug 2012 10:32:13 +0800 Subject: [PATCH] Admin app login form should use swapped user model --- django/contrib/admin/forms.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/django/contrib/admin/forms.py b/django/contrib/admin/forms.py index e10c92afcf..6d72b5b373 100644 --- a/django/contrib/admin/forms.py +++ b/django/contrib/admin/forms.py @@ -4,7 +4,7 @@ from django import forms from django.contrib.auth import authenticate 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 _ 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 '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. + user_model = get_user_model() try: - user = User.objects.get(email=username) - except (User.DoesNotExist, User.MultipleObjectsReturned): + user = user_model.objects.get(email=username) + except (user_model.DoesNotExist, user_model.MultipleObjectsReturned): # Nothing to do here, moving along. pass else: