Django logout makes trouble with the error : Reverse for 'logout' with arguments '()' and keyword arguments '{}' not found

Django logout makes trouble with the error : Reverse for 'logout' with arguments '()' and keyword arguments '{}' not found

我的错误如下:

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

我的'urls.py'如下:

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

我的'views.py'如下:

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

我在 'navbar.html' 中注销的代码如下:

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

我完全不明白我错过了什么。我做错了什么吗?

您在正则表达式中有一个不应该出现的逗号。替换

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

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