【发布时间】:2018-07-16 04:06:56
【问题描述】:
我尝试在模板中使用 for 循环,但出现错误。
这是神社:
{% for i in range(1,10) %}
<h2>{{i}}</h2>
{% endfor %}
这是错误:
django.template.exceptions.TemplateSyntaxError: Could not parse the remainder: '(1,10)' from 'range(1,10)'
我有点困惑。这表明range 有问题,甚至不存在,但我已经看到它在其他 Stack Overflow 帖子中被建议作为解决方案,例如这个:
How to simulate while loop in Jinja2
jinja/django 中是否存在范围?如果是,为什么这不起作用,如果不是,最好的选择是什么?
【问题讨论】:
标签: html django django-templates jinja2