Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have read this one, but I am using Django 1.5 and my urls.py do looks like this:

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

since there is something wrong about the logout, I will show you that I have a app accounts,and in the root urls.py it looks like:

url(r'^accounts/', include('accounts.urls', namespace="accounts")),

and in accounts/urls.py,there is something about logout, it looks like this:

url(r'^logout/$', views.logout, name='logout'),

so can any one tell me how can this cause this bug? Thank you very much.

like image 457
shellbye Avatar asked Apr 02 '14 13:04

shellbye


2 Answers

Your problem is

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

$ indicates end of a regex pattern, and the include would not be considered.

Change it to

url(r'^admin/', include(admin.site.urls)),
like image 194
karthikr Avatar answered Nov 20 '22 11:11

karthikr


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

remove $ from this

because $ indicate that you can not override anything at the end of the url and you use "include" with this that mean you are going to append some other url also with this url so this throw a error like "NoReverseMatch"

( This is like you use final and abstract at same class or method in Java ;) )

like image 2
GrvTyagi Avatar answered Nov 20 '22 10:11

GrvTyagi