python - 没有 csrf_token 的 Django 1.4

标签 python django django-csrf

我刚刚将 Django 从 1.2.3 升级到 1.4,并意识到 django.middleware.csrf.CsrfResponseMiddleware 已被弃用。还有其他方法可以让我不必在每个帖子中使用 csrf_token 吗?前端设计者将更容易不必担心 django 特定的 token 。

最佳答案

检查the doc ,特别是csrf_exemptcsrf_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/

相关文章:

python - 如何判断 python 变量中的数据类型?

python - Python如何处理systemctl停止?

python - 对 Django 模型请求的数据进行简单操作

django - 允许 CSRF_TRUSTED_ORIGINS django 中的所有 ip

Django 网站突然要求用户清除 cookie 以获得 CSRF token

django - django 的零星 403 "CSRF FAILURECSRF cookie not set"错误

python - Pandas:扩展掩码以设置区域

python - View 和 urlpattern : problems with import?

python - 没有CSS的Django Admin加载

python - Postgres SQLAlchemy 自动递增不起作用