0

My error is below :

Reverse for 'logout' with arguments '()' and keyword arguments '{}' not found

My 'urls.py' is below :

urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$',HomeView.as_view(), name='home'),
url(r'^about/$',AboutView.as_view(), name='about'),
url(r'^login/$', views.loginView, name='login'),
url(r'^inquiry/$',InquiryView.as_view(), name='inquiry'),
url(r'^service_terms/$',ServiceTermsView.as_view(), name='service_terms'),
url(r'^privacy_terms/$',PrivacyTermsView.as_view(), name='privacy_terms'),
url(r'^logout/$,', views.logoutView, name='logout'),
]

My 'views.py' is below:

@login_required
def logoutView(request):
if request.method == 'POST':
    logout(request)
    print('logout done')
return render(request, 'about.html')

My code for logging out in 'navbar.html' is below:

<li><a href="{% url 'logout' %}">LogOut</a></li>

I totally do not understand what I'm missing. Is there anything I'm doing wrong?

halfer
  • 19,824
  • 17
  • 99
  • 186
LKM
  • 2,410
  • 9
  • 28
  • 53
  • I wonder if this should be closed as "simple typographical error", given that the solution was just a comma in the wrong place? – halfer Dec 18 '16 at 10:34

1 Answers1

2

You have a comma in the regex that shouldn't be there. Replace

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

with

url(r'^logout/$', views.logoutView, name='logout'),
Alasdair
  • 298,606
  • 55
  • 578
  • 516