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方法,如果定義了什么變量函數都會先執行