码迷,mamicode.com
首页 > 其他好文 > 详细

cbv fbv decorator

时间:2018-08-28 23:50:25      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:isp   sts   change   rom   get   protect   add   ssi   miss   

1

 

from django.views.decorator import csrf_exempt,csrf_protect
from django.utils.decorators import method_docorator
from 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):

 

cbv fbv decorator

标签:isp   sts   change   rom   get   protect   add   ssi   miss   

原文地址:https://www.cnblogs.com/infaaf/p/9551376.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!