相关疑难解决方法(0)

在Django模板中构建一个列表

使用此代码:

{% for o in [1,2,3] %}
    <div class="{% cycle 'row1' 'row2' %}">
        {% cycle 'row1' 'row2' %}
    </div>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

我得到一个TemplateSyntaxError:

Could not parse the remainder: '[1,2,3]' from '[1,2,3]'
Run Code Online (Sandbox Code Playgroud)

有没有办法在模板中构建列表?

django django-templates

38
推荐指数
5
解决办法
4万
查看次数

标签 统计

django ×1

django-templates ×1