2
我可以通過兩個數組/列表循環中同時Django模板?Django模板循環
事情是這樣的:
# views.py
a = [{'a':'apple','b':'banana','c':'clementine'},
{'a':'aunt','b':'brother','c':'cousin'},
{'a':'ant','b':'bat','c':'cat'}]
b = [{'d':'dave','f':'fred'},
{'d':'dason','f':'ford'},
{'d':'dance','f':'flamenco']
# something.html
{% for x, y in a and b %}
{{ x.a }},{{ x.c }}<br>
{{ y.f }}
{% endfor %}
涼爽。我會放棄它。我只問,因爲有模型的方面我想用的時候,我遍歷窗體 – Sevenearths