我的错误如下:
反向退出'参数'()'和关键字参数' {}'找不到
我的' 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'),
]
我的观点.py'如下:
@login_required
def logoutView(request):
if request.method == 'POST':
logout(request)
print('logout done')
return render(request, 'about.html')
我在 我完全不明白我错过了什么。我有什么不对的吗?<li><a href="{% url 'logout' %}">LogOut</a></li>
答案 0 :(得分:2)
你的正则表达式中有一个逗号,不应该存在。替换
url(r'^logout/$,', views.logoutView, name='logout'),
与
url(r'^logout/$', views.logoutView, name='logout'),