【发布时间】:2019-04-16 11:01:23
【问题描述】:
我目前正在编写 django poll 应用教程,但出现此错误。
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
polls/
admin/
The empty path didn't match any of these.
已经尝试重启服务器,迁移已安装应用的数据和settings.py。然而 Django 教程直到现在才要求你这样做。 在 Windows 10 64 位上工作
投票/urls.py
from django.urls import path
from . import views
urlpatterns=[path('',views.index,name='index'),]
mysite/urls.py
from django.contrib import admin
from django.urls import include,path
urlpatterns=[path('polls/',include('polls.urls')),path('admin/',admin.site.urls')),]
结果应该是来自views.py文件的响应
【问题讨论】:
-
你能解释一下什么不起作用吗?可以提供浏览器截图吗?
-
您没有正确阅读教程。甚至还有针对您遇到的问题的特定提示,并带有一个绿色框以突出显示它:“找不到页面?如果您在此处收到错误页面,请检查您要去
http://localhost:8000/polls/而不是http://localhost:8000/。” -
还要注意最后有/,所以你得去localhost:8000/polls/
-
40分钟后回复,我得先走一会
-
我也试过 polls/ 还是一样,不返回索引函数请求
标签: django