zoukankan      html  css  js  c++  java
  • cbv fbv decorator

    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):
  • 相关阅读:
    keepass
    gpg
    Wireshark实践
    ssh
    namp
    第十二周
    第十一周
    第十周总结
    第九周学习总结
    编程语言
  • 原文地址:https://www.cnblogs.com/infaaf/p/9551376.html
Copyright © 2011-2022 走看看