django disabled csrf

django disabled csrf


 

  • Function attempts
  • from django.views.decorators.csrf import csrf_exempt
    
    @csrf_exempt
    def  your_func_view(request):
        pass

     

  • Like trying to
  • from django.views.decorators.csrf import csrf_exempt
    
    class 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

     

Guess you like

Origin www.cnblogs.com/ivy-blogs/p/11445553.html