Ticket #7259: 1.diff
File 1.diff, 1.3 KB (added by , 16 years ago) |
---|
-
django/contrib/admin/views/decorators.py
84 84 message = ERROR_MESSAGE 85 85 if '@' in username: 86 86 # Mistakenly entered e-mail address instead of username? Look it up. 87 users = list(User.objects.filter(email=username)) 88 if len(users) == 1: 89 message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username 90 else: 87 try: 88 user = User.objects.get(email=username) 89 except (User.DoesNotExist, User.MultipleObjectsReturned): 91 90 # Either we cannot find the user, or if more than 1 92 91 # we cannot guess which user is the correct one. 93 92 message = _("Usernames cannot contain the '@' character.") 93 else: 94 message = _("Your e-mail address is not your username. Try '%s' instead.") % user.username 94 95 return _display_login_form(request, message) 95 96 96 97 # The user data is correct; log in the user in and continue.