标签:rom obj login port isp request min log 设置
1.在utils/新建一个文件minx_utils.py文件里面
# coding=utf-8
from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator
class LoginRequiredMixin(object):
@method_decorator(login_required(login_url=‘/login/‘))
def dispatch(self,request,*args,**kwargs):
return super(LoginRequiredMixin,self).dispatch(request,*args,**kwargs)
2.在views文件里面
from utils.mixin_utils import LoginRequiredMixin
将类改为:
class CourseInfoView(LoginRequiredMixin,View)
标签:rom obj login port isp request min log 设置
原文地址:http://www.cnblogs.com/chenyang13677/p/7774101.html