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>
On Saturday, November 24, 2012 5:48:29 PM UTC-5, Sergiy Khohlov wrote:
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>:
> 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 %}
>
> --
> 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 .
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/-/vZnRe-IPpLEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment