Tutorial Part 3: loading index.html in browser

64 views
Skip to first unread message

Luisa Beck

unread,
Nov 24, 2012, 10:38:37 PM11/24/12
to django...@googlegroups.com
I'm in the process of going through the Django tutorials. 
I'm having trouble with loading the index.html file into the browser. I don't see a bulleted-list containing the "What's up" poll from Tutorial 1. Instead, I'm simply seeing the code that I pasted from green box (see middle of the page in the tutorial- I've also pasted it below). 
The tutorial says "put the following code in that template". Does it mean that the code is supposed to go into the index.html file that I created?

Thanks!

{% if latest_poll_list %}
    <ul>
    {% for poll in latest_poll_list %}
        <li><a href="/polls/{{ poll.id }}/">{{ poll.question }}</a></li>
    {% endfor %}
    </ul>
{% else %}
    <p>No polls are available.</p>
{% endif %}

Xavier Ordoquy

unread,
Nov 24, 2012, 10:45:56 PM11/24/12
to django...@googlegroups.com
Hi Luisa,

Le 24 nov. 2012 à 23:38, Luisa Beck <emmi...@gmail.com> a écrit :

I'm in the process of going through the Django tutorials. 
I'm having trouble with loading the index.html file into the browser. I don't see a bulleted-list containing the "What's up" poll from Tutorial 1. Instead, I'm simply seeing the code that I pasted from green box (see middle of the page in the tutorial- I've also pasted it below). 
The tutorial says "put the following code in that template". Does it mean that the code is supposed to go into the index.html file that I created?

You are probably looking at the file itself instead of the page rendered by the server.
Is that the result you had while looking at http://localhost:8000/polls/ ?

Regards,
Xavier Ordoquy.

Thanks!

{% if latest_poll_list %}
    <ul>
    {% for poll in latest_poll_list %}
        <li><a href="/polls/{{ poll.id }}/">{{ poll.question }}</a></li>
    {% endfor %}
    </ul>
{% else %}
    <p>No polls are available.</p>
{% endif %}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/xwta_28JByIJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Sergiy Khohlov

unread,
Nov 24, 2012, 10:48:01 PM11/24/12
to django...@googlegroups.com
Near too.

simple example of your fitst template:
http://www.djangobook.com/en/2.0/chapter04.html

remove all after <body> to </body> and place your code inside this....

2012/11/25 Luisa Beck <emmi...@gmail.com>:

Luisa Beck

unread,
Nov 25, 2012, 12:55:27 PM11/25/12
to django...@googlegroups.com
Thank you Xavier and Sergiy for your responses. 

To clarify: I put the following code (see below) into my index.html file and got a page displaying the code (rather than a list) when I rendered it in my browser by my local server:

Could the problem have to do with my file system? I created a directory called 'templates' in the inner 'mysites' folder and created another directory within that called 'polls'. That's where I put the index.html file. And I also edited TEMPLATE_DIRS in my settings.py to tell Django the absolute path to index.html. 

Any more thoughts about this? Thank you!


<html>

<head><title>Test</title></head>


<body>

{% if latest_poll_list %}

    <ul>

    {% for poll in latest_poll_list %}

        <li><a href="/polls/{{ poll.id }}/">{{ poll.question }}</a></li>

    {% endfor %}

    </ul>

{% else %}

    <p>No polls are available.</p>

{% endif %}


</body>

</html>

Sergiy Khohlov

unread,
Nov 25, 2012, 1:15:30 PM11/25/12
to django...@googlegroups.com
looks like you have a problem with template processor
could you please check setting.py section TEMPLATE_CONTEXT_PROCESSORS

2012/11/25 Luisa Beck <emmi...@gmail.com>:
> https://groups.google.com/d/msg/django-users/-/vZnRe-IPpLEJ.

Luisa Beck

unread,
Nov 25, 2012, 1:34:26 PM11/25/12
to django...@googlegroups.com
Mm, I don't have a TEMPLATE_CONTEXT_PROCESSORS section in the setting.py section. 
The setting.py file in my version of Django only includes TEMPLATE_DEBUG, TEMPLATE_LOADERS and TEMPLATE_DIRS. 

Could you specify what you mean? Thank you. 

Luisa Beck

unread,
Nov 25, 2012, 1:36:29 PM11/25/12
to django...@googlegroups.com
Also, I get the following error message when rendering the page with my local server:

TemplateSyntaxError at /polls/

Could not parse the remainder: '<a href="http://poll.id/">poll.id</a>' from '<a href="http://poll.id/">poll.id</a>'

Sergiy Khohlov

unread,
Nov 25, 2012, 8:47:45 PM11/25/12
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages