網站首頁 編程語言 正文
??? django1.21加入了防止CSRF攻擊的模塊。
??? 這是django的debug模式下給出的錯誤提示頁面。
Forbidden (403)
CSRF verification failed. Request aborted.
Help
Reason given for failure:
CSRF token missing or incorrect.
In general, this can occur when there is a genuine Cross Site Request Forgery, or when Django's CSRF mechanism has not been used correctly. For POST forms, you need to ensure:
- The view function uses
RequestContext
for the template, instead ofContext
. - In the template, there is a
{% csrf_token %}
template tag inside each POST form that targets an internal URL. - If you are not using
CsrfViewMiddleware
, then you must usecsrf_protect
on any views that use thecsrf_token
template tag, as well as those that accept the POST data.
You're seeing the help section of this page because you have DEBUG = True
in your Django settings file. Change that to False
, and only the initial error message will be displayed.
You can customize this page using the CSRF_FAILURE_VIEW setting.
?
??? 在用戶用POST方法提交頁面信息的時候,有時會遇到這樣的錯誤。在網上找了一些解決方案,其中比較方便的一個是在settings.py里面的MIDDLEWARE_CLASSES 中加入'django.middleware.csrf.CsrfResponseMiddleware', 錯誤就消除了。
原文鏈接:https://blog.csdn.net/ayck2008/article/details/5719262
- 上一篇:微信小程序以post方式提交
- 下一篇:正則——16進制顏色
相關推薦
- 2023-01-11 pytorch使用-tensor的基本操作解讀_python
- 2021-12-07 基于Kubernetes實現前后端應用的金絲雀發布(兩種方案)_C#教程
- 2022-08-26 Input標簽自動校驗功能去除實現_React
- 2022-10-23 C#中const,readonly和static關鍵字的用法介紹_C#教程
- 2023-07-08 keycloak更新token調用updateToken函數無效,解決辦法
- 2022-05-14 Python偽隨機數模塊random詳解_python
- 2023-05-31 Pandas.DataFrame刪除指定行和列(drop)的實現_python
- 2022-03-28 go實現一個分布式限流器的方法步驟_Golang
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支