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