如何给cbv的程序添加装饰器

引入method_decorator模块

1,直接在类上加装饰器

@method_decorator(test,name=‘dispatch’)

class Loginview(view)

2,直接在处理的函数前加装饰器

@method_decorator(test)

  def post(self,request,*args,**kwargs):

    pass

posted @ 2019-02-18 14:49  三冬三夏  阅读(394)  评论(0编辑  收藏  举报