How to use Dictionary Key and Value in Django for Loop
To use both dictionary keys and values inside a for loop in your Django templates, write it like this:
{% for key, value in output.items %}
{{ key }}
{{ value }}
{% endfor %}
The important thing to observe in the above statement is the key
is passed before the value
and .items
is passed after the name of the dictionary you wish to iterate over.