title: Django dot-lookup syntax to access variable attributes
body: <pre><code>&lt;h1&gt;{{ question.question_text }}&lt;/h1&gt;
  &lt;ul&gt;
  {% for choice in question.choice_set.all %}
      &lt;li&gt;{{ choice.choice_text }}&lt;/li&gt;
  {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
  <p>The template system uses dot-lookup syntax to access variable attributes. In the example of {{ question.question_text }}, first Django does a dictionary lookup on the object question. Failing that, it tries an attribute lookup – which works, in this case. If attribute lookup had failed, it would’ve tried a list-index lookup.</p>
  
  <p>What is the difference between dictionary, attribute, and list-index lookup?</p>