之前写python用到form表单时一切正常,今天忽然爆了一个摸不着头脑的错误。错误信息详情如下
RuntimeError at /details
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/details/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings.
Request Method: POST
Request URL: http://127.0.0.1:8000/details
Django Version: 2.0.1
Exception Type: RuntimeError
Exception Value:
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/details/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings.
Exception Location: D:\untitled5\venv\lib\site-packages\django\middleware\common.py in get_full_path_with_slash, line 99
Python Executable: D:\untitled5\venv\Scripts\python.exe
Python Version: 3.6.3
Python Path:
['D:\\untitled5',
'D:\\untitled5',
'D:\\untitled5\\venv\\Scripts\\python36.zip',
'C:\\ProgramData\\Anaconda3\\DLLs',
'C:\\ProgramData\\Anaconda3\\lib',
'C:\\ProgramData\\Anaconda3',
'D:\\untitled5\\venv',
'D:\\untitled5\\venv\\lib\\site-packages',
'D:\\untitled5\\venv\\lib\\site-packages\\setuptools-28.8.0-py3.6.egg',
'D:\\untitled5\\venv\\lib\\site-packages\\pip-9.0.1-py3.6.egg',
'C:\\Program Files\\JetBrains\\PyCharm '
'2017.3\\helpers\\pycharm_matplotlib_backend']
Server time: Wed, 17 Jan 2018 03:45:18 +0000
经过多次查证,发现是form表单提交的action没有以‘/’结尾,添加上即可