相关疑难解决方法(0)

循环的Django模板.会员之前

我想创建这样的循环:

{% for object in objects %}
    {% if object.before != object %}
         {{ object }} this is different
    {% else %}
        {{ object }} this is the same
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

基于https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#for我不能.真的没有简单的方法吗?或者我只需要使用计数器并检查objects[counter-1]

PS .before是理论上的,对象是简单的查询列表.我想采取与当前循环成员之前遇到的循环成员做一些事情.

django templates for-loop

0
推荐指数
1
解决办法
1934
查看次数

标签 统计

django ×1

for-loop ×1

templates ×1