iterate dict value in django template code example
Example 1: iterate over dictionary django
{% for key, value in data.items %}
<tr>
<td> Key: {{ key }} </td>
<td> Value: {{ value }} </td>
</tr>
{% endfor %}
Example 2: django template render dictionary
return render_to_response('results.html',
{'data': sorted(results_dict.iteritems())})
return render_to_response('results.html',
{'data': sorted(results_dict.items())})
{% for key, value in data.items() %}
<tr>
<td> {{ key }}: </td> <td> {{ value }} </td>
</tr>
{% endfor %}