I have the following view:
from django.shortcuts import render
def ini (request):
dic = {"nombre" : "Mauro", "apellido" : "London", "sexo" : "M"}
return render(request, "ini.html", dic )
and the ini.html:
{% extends 'base.html' %}
{% block content %}
<body>
<h1>Esto es una prueba {{ nombre }} {{ apellido }}</h1>
<ul>
{% for valor in dic %}
<li>{{ dic[valor] }}</li>
{% endfor %}
</ul>
</body>
{% endblock %}
My question: I see that both the dictionary key "name" and "surname" are printed if I refer directly to it ... but I do not know how to print the dictionary by going through a for. I do it as it is done in python but I get an error.
I've tried with:
{% extends 'base.html' %}
{% block content %}
<body>
<h1>Esto es una prueba {{ nombre }} {{ apellido }}</h1>
<ul>
{% for key, value in dic.items %}
<li>{{ key }} : {{ value }}</li>
{% endfor %}
</ul>
</body>
{% endblock %}
does not give an error but does not print anything ....