首页 > 解决方案 > 在没有上下文变量的模板中循环

问题描述

可以使用仅使用数字而不是模板中的上下文变量的循环,例如:

{% for (int i = 22; i < 65; ++i) %}
<input id="name_{{i}}" type="number" value="{{i}}">
{% endfor %}

如果可以做到,我该怎么做?提前致谢。

标签: pythondjangodjango-templates

解决方案


You can just use:

for i in range(22,64):


推荐阅读