34、Django实战第34天:退出登录
编辑users.view.spy
... from django.contrib.auth import authenticate, login, logout from django.http import HttpResponseRedirect class LogoutView(View): '''退出登录''' def get(self, request): logout(request) from django.core.urlresolvers import reverse return HttpResponseRedirect(reverse('index'))
编辑mxonline.urls.py
... from users.views import LogoutView urlpatterns = [ ... url(r'logout/$', LogoutView.as_view(), name='logout'), ]
在三个继承模板里面配置登出url
每天进步一点,加油!