Realisieren Sie so etwas wie eine Python-Zip-Funktion in einer Vorlage.
python
fist_name_list = ["Ichiro", "Hideki", "Held"]
second_name_list = ["Suzuki", "Matsui", "Noshige"]
temp_list = []
for i, _ in enumerate(fist_name_list):
temp_list.append({
'fist_name': fist_name_list[i],
'second_name': fist_name_list[i],
})
render_to_response(
'test.html',
{'temp_list': temp_list,}
)
test.html
{% for fsname in temp_list %}
{{fsname.fist_name}}
{{fsname.second_name}}
{% endfor %}
Recommended Posts