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

StackOverflow https://stackoverflow.com/questions/22813071

  •  26-06-2023
  •  | 
  •  

سؤال

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.

هل كانت مفيدة؟

المحلول

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)),

نصائح أخرى

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 ;) )

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top