我正在使用Django模板,在循环迭代期间需要打印一次我的语句。我试过{% ifchanged %}
,但在两个循环中都不起作用。你知道吗
使用{% ifchanged %}
可以在单个循环下工作,但我正在两个循环中尝试。你知道吗
例如:
{% for i in j %}
{% for k in j %}
{% ifchanged %}
//something here//
{% endifchanged %}
{% endfor %}
{% endfor %}
然而,在这种情况下,它不起作用。你知道吗
Tags:
还有
forloop.first
。你知道吗请参阅the Django Built-in template tags and filters documentation,以获取与forloops相关联的变量。你知道吗
还有一个
forloop.last
,如果它需要显示在末尾,还有一个forloop.counter
。你知道吗相关问题 更多 >
编程相关推荐