Django @csrf_exempt not working in class View

前端 未结 3 632
半阙折子戏
半阙折子戏 2021-01-11 21:43

I have an application in Django 1.9 that uses SessionMiddleware. I would like to create an API for this application inside the same project, but when doing a POST request it

3条回答
  •  日久生厌
    2021-01-11 21:58

    DO NOT USE csrf_exempt with Django REST framework.

    This won't work because the SessionAuthentication enforces the csrf check anyway.

    Please make sure you use the csrf token in your AJAX requests. Django has a comprehensive documentation about it

提交回复
热议问题