ImportError at /admin/logout/
|Reported by:||Eric B <ebartels@…>||Owned by:||nobody|
|Severity:||Keywords:||auth importerror logout nfa-blocker|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||yes|
I'm getting an ImportError at /admin/logout/
Traceback: File "/home/mrmelve/dev/python-local/django/core/handlers/base.py" in get_response 82. response = callback(request, *callback_args, **callback_kwargs) File "/home/mrmelve/dev/python-local/django/contrib/admin/sites.py" in root 113. return self.logout(request) File "/home/mrmelve/dev/python-local/django/contrib/admin/sites.py" in logout 197. from django.contrib.auth.views import logout File "/home/mrmelve/dev/python-local/django/contrib/auth/views.py" in <module> 1. from django.contrib.auth.forms import AuthenticationForm File "/home/mrmelve/dev/python-local/django/contrib/auth/forms.py" in <module> 1. from django.contrib.auth.models import User File "/home/mrmelve/dev/python-local/django/contrib/auth/models.py" in <module> 369. from django.contrib.auth import admin File "/home/mrmelve/dev/python-local/django/contrib/auth/admin.py" 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.
Change History (9)
Changed 8 years ago by Eric B <ebartels@…>
comment:1 Changed 8 years ago by jacob
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted