djangoproject.com tutorial part 3

101 views
Skip to first unread message

Tri Vo

unread,
Oct 19, 2014, 11:31:57 PM10/19/14
to django...@googlegroups.com
So I am following the tutorial in this site, and copy and the first three codes into my project (polls/views.py, polls/urls.py, and mysite/urls/py)
https://docs.djangoproject.com/en/1.7/intro/tutorial03/

polls/views.py
from django.http import HttpResponse


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


polls/urls.py
from django.conf.urls import patterns, url

from polls import views

urlpatterns = patterns('',
    url(r'^$', views.index, name='index'),
)

The next step is to point the root URLconf at the polls.urls module. In mysite/urls.pyinsert an include(), leaving you with:

mysite/urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin

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

When I launch my site, nothing changes. I do not see the "hello, world..." message at all. What did I do wrong?

Lee

unread,
Oct 20, 2014, 6:48:33 AM10/20/14
to django...@googlegroups.com
When you say nothing changes, how are you calling the page? And what do you see in your browser - any error message or stack trace or is it just a blank page?

Also I assume the below were copied from the tutorial. Can you post the contents of the three files as you typed them in your code?

Tri Vo

unread,
Oct 20, 2014, 7:01:56 PM10/20/14
to django...@googlegroups.com
I am calling the page with "python manage.py runserver 0.0.0.0:8000" When I load up the page before adding the views and urls files, I see the polls and everything that I have set up with the codes from the previous pages of the tutorial. After adding the  views and urls files, the page looks the same like, even though the direction tells me that I should see the "Hello world" message that I put in the views file. I ran another directory with different way to put up the views like in this tutorial (http://www.djangobook.com/en/2.0/chapter03.html) and I got the views working by itself, but using the djangoproject tutorial, I do not see the message.

Daniel Roseman

unread,
Oct 21, 2014, 6:42:46 AM10/21/14
to django...@googlegroups.com
On Tuesday, 21 October 2014 00:01:56 UTC+1, Tri Vo wrote:
I am calling the page with "python manage.py runserver 0.0.0.0:8000" When I load up the page before adding the views and urls files, I see the polls and everything that I have set up with the codes from the previous pages of the tutorial. After adding the  views and urls files, the page looks the same like, even though the direction tells me that I should see the "Hello world" message that I put in the views file. I ran another directory with different way to put up the views like in this tutorial (http://www.djangobook.com/en/2.0/chapter03.html) and I got the views working by itself, but using the djangoproject tutorial, I do not see the message.

You didn't read closely enough:

"You have now wired an index view into the URLconf. Go to **http://localhost:8000/polls/** in your browser, and you should see the text “Hello, world. You’re at the polls index.”, which you defined in the index view."

Note the address.
--
DR.

Tri Vo

unread,
Oct 21, 2014, 1:14:34 PM10/21/14
to django...@googlegroups.com
Ok, I forgot say this. I'm using a different server to run Django. It works on the server that I am using. 

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/OuG_9XUozlQ/unsubscribe.
To unsubscribe from this group and all its topics, 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/ee6f6ec9-f8e6-4101-8aa4-3e388a9d8ffa%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Lee

unread,
Oct 21, 2014, 5:36:07 PM10/21/14
to django...@googlegroups.com
Im not sure I understand so maybe I am stating the obvious here... but "python manage.py runserver" shouldnt call the page. It should start your dev server. Then you call http://localhost:8000/polls as Daniel mentioned when the server is started. 

Tri Vo

unread,
Nov 1, 2014, 2:14:46 PM11/1/14
to django...@googlegroups.com
I've figure out the problem. I was supposed to not have "/admin/" in the link.
Reply all
Reply to author
Forward
0 new messages