Python - render with csrf protection

后端 未结 3 1019
醉话见心
醉话见心 2021-01-13 18:42

I\'ve read several posts about csrf protection in Django, including Django\'s documentation , but I\'m still quite confused in how to use it correctly.

The clearest

3条回答
  •  一生所求
    2021-01-13 19:21

    As far as I remember Django has its own middleware for the csrf protection that handles everthing transparently for you. Just include the {% csrf_token %} inside you forms. CSRF token is mandatory for POST requests (except you use the @csrf_exempt decorator). So a form would be:

    {% csrf_token %} your input fields and submit button...

    Hope this helps.

提交回复
热议问题