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

搞定

相关推荐
fish_study_csdn13 分钟前
pytest 技术总结
开发语言·python·pytest
咖啡调调。22 分钟前
使用Django框架表单
后端·python·django
BO_S__26 分钟前
python调用ffmpeg对截取视频片段,可批量处理
python·ffmpeg·音视频
就叫飞六吧1 小时前
如何判断你的PyTorch是GPU版还是CPU版?
人工智能·pytorch·python
pyengine2 小时前
基于pandoc的MarkDown格式与word相互转换小工具开发(pyqt5)
开发语言·python·qt·word
YuSun_WK2 小时前
配置MambaIRv2: Attentive State Space Restoration的环境
开发语言·python
Nick_zcy2 小时前
开发基于python的商品推荐系统,前端框架和后端框架的选择比较
开发语言·python·前端框架·flask·fastapi
一点.点3 小时前
李沐动手深度学习(pycharm中运行笔记)——04.数据操作
pytorch·笔记·python·深度学习·pycharm·动手深度学习
Niuguangshuo3 小时前
Python 设计模式:访问者模式
python·设计模式·访问者模式
Jamesvalley3 小时前
【Django】新增字段后兼容旧接口 This field is required
后端·python·django