Python - render with csrf protection

后端 未结 3 1156
醉话见心
醉话见心 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:24

    As long as you have the "django.middleware.csrf.CsrfViewMiddleware" listed in your MIDDLEWARE_CLASSES variable in the settings file you should be to just have {% csrf_token %} in your templates.

    There's a lot more useful info in the docs: https://docs.djangoproject.com/en/dev/ref/contrib/csrf/

提交回复
热议问题