Having trouble with Django tutorial

68 views
Skip to first unread message

Yves S. Garret

unread,
Mar 2, 2017, 2:40:09 PM3/2/17
to Django users
Hi all,

I'm going through this tutorial:

And the problem that I'm having is when I start the 'polls' application from inside my project and then go to localhost:8000/polls, I get a 404.

Page not found (404)

Request Method:GET
Request URL:http://localhost:8000/polls

Using the URLconf defined in learning_python.urls, Django tried these URL patterns, in this order:

  1. ^admin/

The current URL, polls, didn't match any of these.



I did everything as the tutorial told me, so I'm a little bit lost as to why this is happening.  Thanks in advance.

Vijay Khemlani

unread,
Mar 2, 2017, 4:09:58 PM3/2/17
to django...@googlegroups.com
Did you do this step?

The next step is to point the root URLconf at the polls.urls module. Inmysite/urls.py, add an import for django.conf.urls.include and insert an include() in the urlpatterns list, so you have:

mysite/urls.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),
]

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/56610bfb-c82b-426c-8346-ec8abe2300d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yves S. Garret

unread,
Mar 3, 2017, 1:19:43 PM3/3/17
to Django users
Yes.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Vijay Khemlani

unread,
Mar 3, 2017, 1:35:47 PM3/3/17
to django...@googlegroups.com
How does your learning_python.urls look like?

On 3/3/17, Yves S. Garret <yoursurr...@gmail.com> wrote:
> Yes.
>
> On Thursday, March 2, 2017 at 11:09:58 AM UTC-5, Vijay Khemlani wrote:
>>
>> Did you do this step?
>>
>> The next step is to point the root URLconf at the polls.urls module. In
>> mysite/urls.py, add an import for django.conf.urls.include and insert an
>> include()
>> <https://docs.djangoproject.com/en/1.10/ref/urls/#django.conf.urls.include>
>> in
>> the urlpatterns list, so you have:
>> mysite/urls.py
>>
>> from django.conf.urls import include, urlfrom django.contrib import admin
>> urlpatterns = [
>> url(r'^polls/', include('polls.urls')),
>> url(r'^admin/', admin.site.urls),]
>>
>>
>> On Thu, Mar 2, 2017 at 11:40 AM, Yves S. Garret <yoursurr...@gmail.com
>> <javascript:>> wrote:
>>
>>> Hi all,
>>>
>>> I'm going through this tutorial:
>>> https://docs.djangoproject.com/en/1.10/intro/tutorial01/
>>>
>>> And the problem that I'm having is when I start the 'polls' application
>>> from inside my project and then go to localhost:8000/polls, I get a 404.
>>>
>>> Page not found (404)
>>> Request Method: GET
>>> Request URL: http://localhost:8000/polls
>>>
>>> Using the URLconf defined in learning_python.urls, Django tried these
>>> URL patterns, in this order:
>>>
>>> 1. ^admin/
>>>
>>> The current URL, polls, didn't match any of these.
>>>
>>>
>>> I did everything as the tutorial told me, so I'm a little bit lost as to
>>>
>>> why this is happening. Thanks in advance.
>>>
>>> --
>>> 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 <javascript:>.
>>> To post to this group, send email to django...@googlegroups.com
>>> <javascript:>.
>>> <https://groups.google.com/d/msgid/django-users/56610bfb-c82b-426c-8346-ec8abe2300d5%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d1be737c-05de-4f0b-8dd0-abe7ac3f0aa4%40googlegroups.com.

Yves S. Garret

unread,
Mar 3, 2017, 1:58:37 PM3/3/17
to Django users
Like this:

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

urlpatterns = [
  url(r'^polls/', urls),
  url(r'^admin/', admin.site.urls),
]

Is there a way to print out strings to indicate where the problem is?

Vijay Khemlani

unread,
Mar 3, 2017, 3:04:32 PM3/3/17
to django...@googlegroups.com
You should import the polls urls as it appears in the tutorial

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

On 3/3/17, Yves S. Garret <yoursurr...@gmail.com> wrote:
> Like this:
>
> from django.conf.urls import include, url
> from django.contrib import admin
>
> urlpatterns = [
> url(r'^polls/', urls),
> url(r'^admin/', admin.site.urls),
> ]
>
> Is there a way to print out strings to indicate where the problem is?
>
> On Friday, March 3, 2017 at 8:35:47 AM UTC-5, Vijay Khemlani wrote:
>>
>> How does your learning_python.urls look like?
>>
>> https://groups.google.com/d/msgid/django-users/d1be737c-05de-4f0b-8dd0-abe7ac3f0aa4%40googlegroups.com.
>>
>>
>> > For more options, visit https://groups.google.com/d/optout.
>> >
>>
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4f860c1e-cedc-4719-af38-31a6a7c87d4f%40googlegroups.com.

Yves S. Garret

unread,
Mar 3, 2017, 4:39:16 PM3/3/17
to Django users
This is what I have:

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

I'm still encountering the same problem.

Yves S. Garret

unread,
Mar 3, 2017, 5:04:28 PM3/3/17
to Django users
Is this learning_python/urls.py or learning_python/learning_python/urls.py?

Vijay Khemlani

unread,
Mar 3, 2017, 8:04:30 PM3/3/17
to django...@googlegroups.com
Starting from the project root (the directory that contains your
manage.py file), that project's main url file should be in

learning_python/urls.py

also, there should be only two urls.py in your project directory, the
one for the project and the other inside the polls app.

On 3/3/17, Yves S. Garret <yoursurr...@gmail.com> wrote:
> Is this learning_python/urls.py or learning_python/learning_python/urls.py?
>
> On Friday, March 3, 2017 at 10:04:32 AM UTC-5, Vijay Khemlani wrote:
>>
>> You should import the polls urls as it appears in the tutorial
>>
>> url(r'^polls/', include('polls.urls')),
>>
>> https://groups.google.com/d/msgid/django-users/4f860c1e-cedc-4719-af38-31a6a7c87d4f%40googlegroups.com.
>>
>>
>> > For more options, visit https://groups.google.com/d/optout.
>> >
>>
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1935d672-eabb-4fcb-a496-dc7255baccb2%40googlegroups.com.

Yves S. Garret

unread,
Mar 5, 2017, 12:21:52 PM3/5/17
to Django users
Yes, that did it. I placed the file into learning_python/learning_python and everything just worked.

Thank you

Reply all
Reply to author
Forward
0 new messages