Opened 17 years ago

Closed 17 years ago

#7120 closed (worksforme)

django.contrib.admin.sites uses User but doesn't import it

Reported by: Maciej Wiśniowski Owned by: nobody
Component: contrib.admin Version: newforms-admin
Severity: Keywords: sites user import
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

django.contrib.admin.sites has no import of User model but uses it:

This fragment uses User object:

            if u'@' in username:
                # Mistakenly entered e-mail address instead of username? Look it up.
                try:
                    user = User.objects.get(email=username)
                except User.DoesNotExist:
                    message = _("Usernames cannot contain the '@' character.")
                else:
                    message = _("Your e-mail address is not your username. Try '%s' instead.") % user.username

But in fact it causes error:

File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py", line 226, in login
NameError: global name 'User' is not defined

Simple import:

    from django.contrib.auth.models import User

should be added.

Change History (1)

comment:1 by Brian Rosner, 17 years ago

Resolution: worksforme
Status: newclosed

The import does exist at the top of the view of the fragment you posted. This may be related to #6718. Marking as worksforme. Reopen with specific information to reproduce.

Note: See TracTickets for help on using tickets.
Back to Top