Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#6718 closed (fixed)

ImportError at /admin/logout/

Reported by: Eric B <ebartels@…> Owned by: nobody
Component: Contrib apps Version: newforms-admin
Severity: Keywords: auth importerror logout nfa-blocker
Cc: post@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no


I'm getting an ImportError at /admin/logout/

File "/home/mrmelve/dev/python-local/django/core/handlers/" in get_response
  82.                 response = callback(request, *callback_args, **callback_kwargs)
File "/home/mrmelve/dev/python-local/django/contrib/admin/" in root
  113.             return self.logout(request)
File "/home/mrmelve/dev/python-local/django/contrib/admin/" in logout
  197.         from django.contrib.auth.views import logout
File "/home/mrmelve/dev/python-local/django/contrib/auth/" in <module>
  1. from django.contrib.auth.forms import AuthenticationForm
File "/home/mrmelve/dev/python-local/django/contrib/auth/" in <module>
  1. from django.contrib.auth.models import User
File "/home/mrmelve/dev/python-local/django/contrib/auth/" in <module>
  369. from django.contrib.auth import admin
File "/home/mrmelve/dev/python-local/django/contrib/auth/" in <module>
  1. from django.contrib.auth.forms import UserCreationForm

Exception Type: ImportError at /admin/logout/
Exception Value: cannot import name UserCreationForm

This looks like a circular import problem in contrib.auth.admin.
From the traceback, importing User imports admin which imports UserCreationForm which imports User again.
Oddly, I haven't experienced this error using the development server, but only when running under mod_python. Also, the problem is somewhat intermittent in that sometimes the logout completes without a problem, but most of the time triggers the import error.

I've attached a patch which avoids the problem by moving the import of UserCreationForm from the top level into the add_view method.

Attachments (1)

logout_importerror.diff (716 bytes) - added by Eric B <ebartels@…> 11 years ago.

Download all attachments as: .zip

Change History (9)

Changed 11 years ago by Eric B <ebartels@…>

Attachment: logout_importerror.diff added

comment:1 Changed 11 years ago by Jacob

Triage Stage: UnreviewedAccepted

comment:2 Changed 11 years ago by Bela Hausmann <post@…>

Cc: post@… added

comment:3 Changed 11 years ago by Michael Newman

Patch needs improvement: set

I believe this error is due to an AlreadyRegistered exception and it will be fixed when that is handled differently. That being said if it is the AlreadyRegistered exception, this patch is really not the way to fix it. Also, I am only able to duplicate this in mod_python; in the runserver environment it doesn't seem to through the error. I think that this error and some other odd AlreadyRegistered errors are due to the way mod_python handles imports.

comment:4 Changed 11 years ago by mariarchi

It also happens to me when I'm trying to log in (mod_python, worker mpm).
Also, why this ticket is not marked as nfa-blocker?

comment:5 Changed 11 years ago by mrts

Keywords: nfa-blocker added

Marking as nfa-blocker. This clearly needs to be fixed one way or other before nfa can be merged.

comment:6 Changed 11 years ago by Marc Garcia

milestone: 1.0 alpha

comment:7 Changed 11 years ago by Brian Rosner

Resolution: fixed
Status: newclosed

(In [7671]) newforms-admin: Fixed #6718 -- Removed a circular import in contrib/auth/ Thanks Eric B.

comment:8 Changed 8 years ago by Jacob

milestone: 1.0 alpha

Milestone 1.0 alpha deleted

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