1
from django.views.decorator import csrf_exempt,csrf_protectfrom django.utils.decorators import method_docoratorfrom django.views import View#@method_decorator(csrf_exempt,name='dispatch')class AbcView(View): @method_decorator(csrf_exempt) def dispatch(self,requests,*args,**kwargs): return super(AbcView,self).dispatch(requests,*args,**kwargs) def get(self,request,): pass
2
@permission_required('aptest.change_hv',login_url="/aptest/loginauth") def f(request): pass
3
@login_required(login_url="/aptest/loginauth") #不需要再使用permission_required()装饰器def add(request):
4
class MyView(LoginRequiredMixin, PermissionRequiredMixin, View)
5
class LoginRequiredMixin(object): @method_decorator(login_required(login_url='/login/')) def dispatch(self,request,*args,**kwargs):