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',]

搞定

相关推荐
2301_765703146 分钟前
Python迭代器(Iterator)揭秘:for循环背后的故事
jvm·数据库·python
追风少年ii25 分钟前
多组学扩展---分子对接pyrosetta
python·数据分析·空间·单细胞
2301_8213696144 分钟前
使用Python进行图像识别:CNN卷积神经网络实战
jvm·数据库·python
m0_561359671 小时前
使用Kivy开发跨平台的移动应用
jvm·数据库·python
编程火箭车1 小时前
04.第一个 Python 程序:Hello World 从编写到运行全解析
python·python第一个程序·python入门报错解决·python新手教程·hello world 程序·python终端运行·pycharm运行代码
qq_423233902 小时前
如何用FastAPI构建高性能的现代API
jvm·数据库·python
疯狂踩坑人2 小时前
【Python版 2026 从零学Langchain 1.x】(二)结构化输出和工具调用
后端·python·langchain
HDO清风2 小时前
CASIA-HWDB2.x 数据集DGRL文件解析(python)
开发语言·人工智能·pytorch·python·目标检测·计算机视觉·restful
weixin_499771552 小时前
Python上下文管理器(with语句)的原理与实践
jvm·数据库·python
weixin_452159552 小时前
高级爬虫技巧:处理JavaScript渲染(Selenium)
jvm·数据库·python