tutorial part3 : polls didn't match URL patterns

301 views
Skip to first unread message

AJ NOURI

unread,
Jan 10, 2014, 3:40:25 AM1/10/14
to django...@googlegroups.com

I have Python 2.7.3

I am new in django and I am following the tutorial 3 at :https://docs.djangoproject.com/en/1.6/intro/tutorial03/

I followed exactly the steps described:

Here is a copy/paste from files in the project:

cat polls/views.py

from django.http import HttpResponse

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

from /mysite: cat urls.py

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)'),
)

cat polls/urls.py

from django.conf.urls import patterns, url

from polls import views

urlpatterns = patterns('',
    url(r'^$', views.index, name='index')
)
The page debug shows the following error: 
enter image description here


It looks like, it doesn't recognize the "polls" pattern in /mysite/urls.py.

Am I missing something?

carlos

unread,
Jan 10, 2014, 10:03:02 AM1/10/14
to django...@googlegroups.com
change this

url(r'^polls/', include('polls.urls')'),

for this

url(r'^', include('polls.urls')'),


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/31d65899-e64f-4f5d-aac7-ea0dd67108f9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

frankel...@gmail.com

unread,
Mar 9, 2014, 5:05:54 PM3/9/14
to django...@googlegroups.com
AJ NOURI,

I had the exact same issue.  The trick for me was to edit the existing file at mysite/mysite/urls.py.  I had previously created a new file at mysite/urls.py (one directory up).  The code from the tutorial works for me now that I have it in the proper directory.  Your message was from a couple of months ago, I wanted to add this in case anyone is stuck at the same place.

Nathan

aliteralmind

unread,
Jul 22, 2014, 10:22:09 PM7/22/14
to django...@googlegroups.com
My problem was that I put the file in the wrong place. It says the file should be `mysite/urls.py`, but it really should be `mysite/mysity/urls.py'.
Reply all
Reply to author
Forward
0 new messages