rednaxela
rednaxela

Reputation: 791

Django Tutorial 3 - URL producing 404 error

I am following the Django 1.6 tutorial 3 (https://docs.djangoproject.com/en/1.6/intro/tutorial03/) and I have become stuck towards the beginning - "Writing your first view".

The Django tutorial first says to edit the views.py, which I have done as follows:

from django.http import HttpResponse

def index(request):
    return HttpResponse("Hello, world. You're at the poll index.")

Then it says to create a urls.py in the same directory, which I have done. My urls.py looks like this:

from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

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

The next instruction is to now check the URL http://localhost:8000/polls/ for the message 'Hello, world. You're at the poll index.' but my browser simply produces the Django 404 error - Page not found.

I'm sure I'm doing something pretty stupid but I can't what is wrong, I've tried restarting the python webserver. I've followed the previous 2 tutorials with success, can anybody help me out?

If it makes a difference, I'm using Windows7, Python 3.4.1 and Django 1.6.5

Upvotes: 3

Views: 350

Answers (1)

Vic Nmkf
Vic Nmkf

Reputation: 701

Your view.py for polls must be in projectname/polls/ directory when first urls.py will be in projectname/projectname/.

Then, if you decide to configure and add more polls app specific urls, you can create urls.py in projectname/polls/.

Upvotes: 2

Related Questions