I create a dictionary, and pass it to my Django template:
my_dict = {'boo': {'id':'42'}, 'hi': {'id':'42'}}
t = get_template('my_site.html')
html = t.render(my_dict)
print(html)
return HttpResponse(html)
My Django template looks like this:
<html>
<body>
Out of Dictionary <div>
{% for key in my_dict %}
<span>{{ key }}</span>
{% endfor %}
</div>
After dictionary
</body>
</html>
My output in the browser looks like this: Out of Dictionary After dictionary
The HTML looks like this:
<html>
<body>
Out of Dictionary <div>
</div>
After dictionary
</body>
</html>
I have also tried the following to get the dict to be recognized:
{% for key in my_dict %}
{% for key in my_dict.items %}
{% for key, value in my_dict.items %}
{% for (key, value) in my_dict.items %}