Django模板中的数字for循环 [英] Numeric for loop in Django templates
本文介绍了Django模板中的数字for循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
How do I write a numeric for
loop in a Django template? I mean something like
for i = 1 to n
解决方案
I've used a simple technique that works nicely for small cases with no special tags and no additional context. Sometimes this comes in handy
{% for i in '0123456789'|make_list %}
{{ forloop.counter }}
{% endfor %}
这篇关于Django模板中的数字for循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文