【发布时间】:2017-04-24 06:51:55
【问题描述】:
我有一个列表['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']。
在我的 django 模板中,我希望输出为
a b
c d
e f
g h
这就是我正在做的:-
{% for i in list|slice:"::2" %}
{{i}} {{}} // how do I get the second element?
{% endfor %}
我错过了什么?
以下是python的等价物:-
for i in range(0, len(list), 2):
print list[i], list[i+1]
【问题讨论】:
标签: django django-templates django-template-filters