异常:
禁止访问 (403)
CSRF验证失败. 请求被中断.
错误原因:
取消csrf验证,否则Django将会拒绝客户端发来的post请求保403响应
解决办法:
取消csrf验证 禁止掉setting.py中MIDDLEWARE中的CsrfViewsMiddleWare的中间件
异常:
RuntimeError at /tieba/data_operation
You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to 127.0.0.1:8001/tieba/data_operation/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings.
![](https://img2020.cnblogs.com/blog/985237/202106/985237-20210618163853313-1506414120.png)
错误原因
提示form的action地址最后不是/结尾的,而且APPEND_SLASH的值是Ture
解决办法
解决方法1 : 将from的action地址改为/结尾
解决方法2 : 修改settings:APPEND_SLASH=False