To access a dictionary element in a Python Django template, we can use the items
property.
For instance, if we have
choices = {'key1':'val1', 'key2':'val2'}
Then we can loop through the choices
entries with
<ul>
{% for key, value in choices.items %}
<li>{{key}} - {{value}}</li>
{% endfor %}
</ul>
We get the key
and value
pairs from choices.items
and then we render them in the li element.