Realize something like a Python zip function in a template.
python
fist_name_list = ["Ichiro", "Hideki", "hero"]
second_name_list = ["Suzuki", "Matsui", "Nomo"]
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