CBV csrf装饰器加入位置
需要加在类的dispatch方法上,加到某个方法上会报错
from django.utils.decorator import method_decorator
from django.views.decorator.csrf import csrf_exempt,csrf_protect
class CBV(APIView):
@method_decorator(csrf_exempt)
def dispatch(self,request,*arg,**kwargs):
return super(CBV,self).dispatch(request,*args,**kwargs)
def get(self,request):
pass