view django render dic code example
Example: django template render dictionary
#In views.py (Python2):
return render_to_response('results.html',
{'data': sorted(results_dict.iteritems())})
#Or in views.py (Python3):
return render_to_response('results.html',
{'data': sorted(results_dict.items())})
#In template file:
{% for key, value in data.items() %}
<tr>
<td> {{ key }}: </td> <td> {{ value }} </td>
</tr>
{% endfor %}