我刚刚将 Django 从 1.2.3 升级到 1.4,并意识到 django.middleware.csrf.CsrfResponseMiddleware 已被弃用。还有其他方法可以让我不必在每个帖子中使用 csrf_token 吗?前端设计者将更容易不必担心 django 特定的 token 。
最佳答案
检查the doc ,特别是csrf_exempt
和 csrf_protect
装饰者。
然后,您可以使用 django.middleware.csrf.CsrfViewMiddleware
进行默认 csrf 保护,并使用 csrf_exempt
来豁免特殊 View ;或者仅对要保护的每个 View 使用 csrf_protect
。
关于python - 没有 csrf_token 的 Django 1.4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10206663/