我想创建这样的循环:
{% 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是理论上的,对象是简单的查询列表.我想采取与当前循环成员之前遇到的循环成员做一些事情.