The empty path didn't match any of these.
PyCharm出现如下错误:
Page not found (404)
Request Method: | GET |
---|---|
Request URL: | http://127.0.0.1:8000/ |
Using the URLconf defined in untitled4.urls
, Django tried these URL patterns, in this order:
- Chamico/
- admin/
The empty path didn't match any of these.
You're seeing this error because you have DEBUG = True
in your Django settings file. Change that to False
, and Django will display a standard 404 page.
原因:
这是我学习Django2.1按照Django官网上的方式来弄的,还是出错,百思不得其解。后来看了大量的博客,发现是path()的问题,path()参数第一个是路径,官网上面让你直接运行 http://127.0.0.1:8000/polls,说的很明白,但是在pycharm上面打开的是http://127.0.0.1:8000 ,所以会出现这样的错误。
解决方法:
1,手动在浏览器的url后面添加 Chamico(针对我的这个代码)
2,或者将对应路径中,path函数中第一个参数置为空字符。