Dotted notation uses periods to reach values inside template data. In a Django template, the same form can access an object attribute, a dictionary value, a list or tuple item, or a no-argument callable. section 3.2 section 3.4
Common Django template lookups include:
- {{ person.name }} reads the name attribute of an object or the name key of a dictionary. section 3.4
- {{ fruit.2 }} reads the third item in a list or tuple; template notation uses a dot where Python would use square brackets. section 3.4
- {{ person.show_name }} invokes show_name() without arguments and renders its result. section 3.4
- {{ instrument.name }} and {{ instrument.cost }} expose fields while a {% for %} loop renders each instrument. section 3.5.2
Rendering instrument data
Given an iterable named instruments containing objects with name and cost attributes, a template can render each one as a list item: {% for instrument in instruments %}<li>{{ instrument.name }}: {{ instrument.cost }}</li>{% endfor %}. If the iterable is empty, an {% empty %} branch can display a fallback message. section 3.5.2
<ul>
{% for instrument in instruments %}
<li> {{instrument.name}}: {{instrument.cost}}</li>
{% endfor %}
</ul>
See dotted notation operating inside a Django template loop that builds an HTML list. section 3.5.2








