Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Simplified control flow for change made in r7535

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7536 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 6f76b9f58d3b34d71f31d088dc629d3337aef24e 1 parent 7e4718f
Luke Plant spookylukey authored
Showing with 6 additions and 11 deletions.
  1. +6 −11 django/contrib/admin/views/decorators.py
17 django/contrib/admin/views/decorators.py
View
@@ -84,18 +84,13 @@ def _checklogin(request, *args, **kwargs):
message = ERROR_MESSAGE
if '@' in username:
# Mistakenly entered e-mail address instead of username? Look it up.
- try:
- users = list(User.objects.filter(email=username))
- if len(users) == 1:
- user = users[0]
- else:
- # Either we cannot find the user, or if more than 1
- # we cannot guess which user is the correct one.
- raise User.DoesNotExist()
- except User.DoesNotExist:
- message = _("Usernames cannot contain the '@' character.")
+ users = list(User.objects.filter(email=username))
+ if len(users) == 1:
+ message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username
else:
- message = _("Your e-mail address is not your username. Try '%s' instead.") % user.username
+ # Either we cannot find the user, or if more than 1
+ # we cannot guess which user is the correct one.
+ message = _("Usernames cannot contain the '@' character.")
return _display_login_form(request, message)
# The user data is correct; log in the user in and continue.
Please sign in to comment.
Something went wrong with that request. Please try again.