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

搞定

相关推荐
麦麦鸡腿堡22 分钟前
Java事件处理机制
java·开发语言·python
谅望者1 小时前
数据分析笔记07:Python编程语言介绍
大数据·数据库·笔记·python·数据挖掘·数据分析
Geo_V1 小时前
LangChain Memory 使用示例
人工智能·python·chatgpt·langchain·openai·大模型应用·llm 开发
小呀小萝卜儿2 小时前
2025-11-15 学习记录--Python-LSTM模型定义(PyTorch)
python·学习·lstm
百锦再2 小时前
第15章 并发编程
android·java·开发语言·python·rust·django·go
laufing3 小时前
pyinstaller 介绍
python·构建打包
谅望者3 小时前
数据分析笔记09:Python条件语循环
笔记·python·数据分析
Auspemak-Derafru3 小时前
从U盘损坏中恢复视频文件并修复修改日期的完整解决方案
python
techzhi4 小时前
Intellij idea 注释模版
java·python·intellij-idea
李昊哲小课4 小时前
wsl ubuntu24.04 cuda13 cudnn9 pytorch 显卡加速
人工智能·pytorch·python·cuda·cudnn