class InfoMG(View):
@method_decorator(csrf_exempt)
@method_decorator(login_required)
def dispatch(self, request, *args, **kwargs):
return super(InfoMG, self).dispatch(request, *args, **kwargs)
def get(self, request):
pass
def post(self, request):
pass
简单说作用就是当请求的get或者post的方法之前执行这个dispatch方法,如果定义了什么变量函数都会先执行
原文:https://www.cnblogs.com/lucktomato/p/15149553.html