django禁用csrf
- 函数试图
-
from django.views.decorators.csrf import csrf_exempt@csrf_exempt
def your_func_view(request):
pass - 类试图
-
from django.views.decorators.csrf import csrf_exemptclass CsrfExemptMixIn(View):
# 禁用csrf
@csrf_exempt
def dispatch(self, request, *args, **kwargs):
return super(CsrfExemptMixIn, self).dispatch(request, *args, **kwargs)class YourClassView(CsrfExemptMixIn):
def post(self, request):
pass