5

I am getting this error when trying to access my admin panel after updating to Django 1.4 - the error is:

NoReverseMatch at /admin/
Reverse for 'logout' with arguments '()' and keyword arguments '{}' not found.

My best guess is that I'm defining a logout urlpattern which is somehow conflicting with the one the admin panel is trying to create? Although, it should be creating /admin/logout, right? I did update my ADMIN_MEDIA_PREFIX to STATIC_URL and moved them to a sub-folder called admin, but that didn't seem to make a difference.

In my urls.py, I have:

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    ...
    ('^logout/$',  RedirectView.as_view(url='/login/index.html')),
    (r'^login/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/fullpath/to/media/login'}),
    (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/fullpath/to/media/static'}),
    (r'^admin/(.*)', include(admin.site.urls)),
)

And in my settings.py, I have:

STATIC_ROOT = '/fullpath/to/myapp/media/static/'
STATIC_URL = '/static/'

INSTALLED_APPS = (
    'django.contrib.auth',
     ...
    'django.contrib.admin',
)
Adam Morris
  • 8,265
  • 12
  • 45
  • 68

1 Answers1

11
(r'^admin/(.*)', include(admin.site.urls)),

Should be

(r'^admin/', include(admin.site.urls)),

(.*) would eat up all anything following admin as the view argument.

Also, do you know what is calling reverse('logout')? In my local 1.4 install, the admin is namespaced and I have to call reverse('admin:logout')

Yuji 'Tomita' Tomita
  • 115,817
  • 29
  • 282
  • 245
  • 2
    Thanks, the (.*) was the problem. I may have been reading the error wrong - after it worked, I tried adding the (.*) back in, and got another error with the reverse lookup error, and it didn't show the admin: prefix the traceback showed it occurring when a reverse('admin:xxx) – Adam Morris Apr 13 '12 at 20:20
  • 2
    I had a very similar issue, but I had `r'^admin/$',`. Changing it back to `r'^admin/,` fixed the issue. – gregoltsov Nov 01 '13 at 12:29