2014-01-13 44 views
0

我似乎无法获得教程https://docs.djangoproject.com/en/1.6/intro/tutorial03/的工作。Django:无法找到index.html网址(Django民意调查教程)

urlpatterns = patterns('', 
    url(r'^polls/', include('polls.urls')), 
    url(r'^admin/', include(admin.site.urls)), 
) 

和index.html在/调查/模板/调查/:试图访问http://127.0.0.1:8000/index.htmlhttp://127.0.0.1:8000/

Page not found (404) 
Request Method: GET 
Request URL: http://127.0.0.1:8000/index.html 
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: 
^polls/ 
^admin/ 
The current URL, index.html, didn't match any of these. 

我/mysite/urls.py集时,我得到以下错误index.html

+0

有关如何通过Django解析url的更多信息,请参见https://docs.djangoproject.com/en/dev/topics/http/urls/。在Django中,url指向_view函数_而不是文件。 _urlconf_(在你的'urls.py'中)定义了url和view函数之间的映射关系 – Anentropic

回答

4

您的urls.py中的网址是您可以访问的网址;所以无论是

http://127.0.0.1:8000/admin/ 
http://127.0.0.1:8000/polls/ 

提供这两个subapps(admin和调查)定义为空字符串(“^ $”),我相信他们俩做一个视图。

事实上,其中一个意见恰巧使用名为“index.html”的模板并不意味着该文件名也用于URL中。

相关问题