Friday, 22 July 2022

django - remove csrf token

 https://stackoverflow.com/questions/16458166/how-to-disable-djangos-csrf-validation



view level :

from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt

@method_decorator(csrf_exempt, name='dispatch')
class TestView(View):
    def post(self, request, *args, **kwargs):
        return HttpResponse('Hello world')


global level:

In setting.py in MIDDLEWARE you can simply remove/comment this line:

'django.middleware.csrf.CsrfViewMiddleware',

No comments:

Post a Comment