Boston Python Workshop/Saturday/Web app project: Difference between revisions

imported>Paulproteus
imported>Paulproteus
Line 581:
We pass in a variable called '''poll''' that points to an instance of the Poll class. So you can pull out more information by writing this into the "polls/detail.html" template:
 
<pre>
<h1>{{ poll.question }}</h1>
<ul>
{% for choice in poll.choice_set.all %}
<li>{{ choice.choice }}</li>
{% endfor %}
</ul>
</pre>
 
The template system uses dot-lookup syntax to access variable attributes. Django's template language is a bit sloppy: in pure Python, the '''.''' (dot) only lets you get attributes from objects. In this example, we are just doing attribute lookup, but in general if you're not sure how to get data out of an object in Django, try '''dot'''.
Anonymous user