[Answered ]-Iterate over one key's dictionary in another dictionary in a Django template

2👍

In Django templates, you cannot use the data['today'] syntax to access the value of a dictionnary, you need to use the . (data.today):

{% for key, value in data.today.items %}
    {{ key }} {{ value }}
{% endfor %}
👤Holt

0👍

try this:
If you want only dictionary field with only ‘today’ key then simply send data[‘today’] from view {‘data’: data[‘today’]} and then render it like:

{% for key, value in data.items %}
    {{ key }} {{ value }}
{% endfor %}

If you want whole dictionary to be sent then,

{% for key, value in data.items %}
    {% for k,v in value.items %}
     {{k}} {{v}}
    {% endfor %}
{% endfor %}

Leave a comment