登录装饰器

from django.shortcuts import redirect

def   loginrequired(view_func):

def wrapper(request, *args, **kwargs):

if request.session.has_key('islogin'):

return view_func(request, *args, **kwargs)

else:

return redirect('/user/login/')

return wrapper

推荐阅读更多精彩内容