提交表单报错
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:8000/mycal/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings
解决方法
第一种方法:提示的url地址不是以/结尾的,在表单form的结尾加上/就行了
第二种方法:去settings配置文件中添加一项配置APPEND_SLASH = False
提交表单时报错
Forbidden (403)
解决方法:
去settings.py文件里面找到MIDDLEWARE下的csrf 如何注释掉它
最后就可以成功输出表单的值了
if 标签报错
今天在学习django的时候用到了if标签
运行时报错:
Could not parse the remainder: '=='add'' from '=='add''
后来才知道django中使用if有特定的格式,如下:
{%if 变量名 判断符 条件%}
!!!判断符左右都要有空格
修改后的代码:
op == 'add' (==的两边都有空格)
解决后就可以完美运行了