Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django 1.4 and NoReverseMatch at /admin/ error

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',
)
like image 787
Adam Morris Avatar asked Apr 13 '12 17:04

Adam Morris


1 Answers

(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')

like image 146
Yuji 'Tomita' Tomita Avatar answered Sep 20 '22 12:09

Yuji 'Tomita' Tomita