Python 轮询应用程序&x2014;django教程不起作用

Python 轮询应用程序&x2014;django教程不起作用,python,django,Python,Django,我正在处理这个问题。我已经到了第六部分的开头 出于某种原因,除了基于类的索引视图之外,我所有基于类的泛型视图都在工作。尝试加载localhost:8000/I时,出现以下错误: Page not found (404) Request Method: GET Request URL: http://localhost:8000/ Using the URLconf defined in mysite.urls, Django tried these URL patterns, in th

我正在处理这个问题。我已经到了第六部分的开头

出于某种原因,除了基于类的索引视图之外,我所有基于类的泛型视图都在工作。尝试加载localhost:8000/I时,出现以下错误:

Page not found (404)
Request Method: GET
Request URL:    http://localhost:8000/

Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
^polls/
^admin/

The current URL, , didn't match any of these.
这是我的mysite/url.py:

from django.conf.urls import include, url
from django.contrib import admin


urlpatterns = [
   url(r'^polls/', include('polls.urls')),
   url(r'^admin/', admin.site.urls),
]
这是我的polls/url.py

from django.conf.urls import url

from . import views

app_name = 'polls'

urlpatterns = [
   url(r'^$', views.IndexView.as_view(), name='index'),
   url(r'^(?P<pk>[0-9]+)/$', views.DetailView.as_view(), name='detail'),
   url(r'^(?P<pk>[0-9]+)/results/$', views.ResultsView.as_view(), name='results'),
   url(r'^(?P<question_id>[0-9]+)/vote/$', views.vote, name='vote'),
]

我错过什么了吗?非常感谢您的帮助。

您的索引url模式位于
polls/url.py
中,您将其包含在
r'^polls/'
下,因此您可以通过以下网址访问:

http://localhost:8000/polls/

http://localhost:8000/
是预期行为,因为您的主
url.py
仅包括
admin/
polls/
处的URL。您必须使用regex
r'^$'
将url模式添加到
main/url.py
以停止404。

谢谢!作为额外的奖励,你的回答教会了我如何思考“索引”,因为它与mysite和polls应用程序中的内容有关。非常感谢。
http://localhost:8000/polls/