0
votes

I can't seem to get the tutorial at https://docs.djangoproject.com/en/1.6/intro/tutorial03/ to work. I get the following error when trying to access http://127.0.0.1:8000/index.html or http://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.

I have /mysite/urls.py set to:

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

And index.html is in /polls/templates/polls/index.html

1
See docs.djangoproject.com/en/dev/topics/http/urls for more info on how urls are resolved by Django. In Django an url points to a view function rather than to a file. The urlconf (in your urls.py) is what defines the mapping between urls and view functions - Anentropic

1 Answers

4
votes

The URLs in your urls.py are the ones you can go to; so either

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

Provided both those subapps (admin and polls) define a view for the empty string ("^$"), which I believe both of them do.

The fact that one of those views happens to use a template named "index.html" doesn't mean that that filename is also used in URLs.