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

posted @ 2018-03-31 17:08  sellsa  阅读(189)  评论(0编辑  收藏  举报