django报错解决 Forbidden (403) CSRF verification failed. Request aborted.

django报错解决 Forbidden (403) CSRF verification failed. Request aborted.

报错内容

bash 复制代码
Forbidden (403)
CSRF verification failed. Request aborted.

Help
Reason given for failure:

    Origin checking failed - https://active-mantis-distinct.ngrok-free.app does not match any trusted origins.
    
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:

解决办法

setting.py 文件加入以下内容

www.***.com

为你当前访问域名

bash 复制代码
CSRF_TRUSTED_ORIGINS = ['https://**.com',]

搞定

相关推荐
爱昏羔6 小时前
下篇:从检索到交互 — 物流RAG问答系统与WebUI全实现
python·langchain·agent
_Jimmy_6 小时前
Agent引用数据库知识过时的增量同步方案
人工智能·python·langchain
min(a,b)7 小时前
学习第 4 天:面向对象与异常处理
python·学习·学习方法
yangshicong9 小时前
第19章:AI安全防护与AI安全
人工智能·python·安全·prompt·ai编程
果汁华9 小时前
Function Calling 与 Python 实战完整指南
开发语言·网络·python
c_lb72889 小时前
2026年不同基础做量化,先找AI能参与的位置
人工智能·python
chenment11 小时前
ComfyUI 自定义节点开发:从零扩展你的图像生成工作流
python·stable diffusion
IT空门:门主11 小时前
Python 基础语法学习路线图
网络·python·学习
互联网中的一颗神经元12 小时前
小白python入门 - 25. SQL 与表设计入门
数据库·python·sql
RSTJ_162513 小时前
PYTHON+AI LLM DAY ONE HUNDRED AND EIGHTEEN
python