網站首頁 編程語言 正文
??? 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-06-05 Python數據分析之堆疊數組函數示例總結_python
- 2023-07-30 vscode自定義用戶代碼片段
- 2022-03-26 Linux快速部署Redis_Redis
- 2022-11-28 詳解Pytorch如何利用yaml定義卷積網絡_python
- 2022-12-01 Go?sync?WaitGroup使用深入理解_Golang
- 2022-03-20 android?Retrofit2網絡請求封裝介紹_Android
- 2022-03-26 C語言猜兇手及類似題目的實現示例_C 語言
- 2022-08-27 如何利用Pandas查詢選取數據_python
- 最近更新
-
- 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同步修改后的遠程分支