如果当前迭代与前一次迭代不同,则循环模板

时间:2013-08-29 19:37:43

标签: html django templates

我想要

{% for user_id, x, y in information %}
    {% if it is the first time that user_id is different from the previous iteration %}
        do something
    {% elseif user_id is different from the user_id in the previous iteration %}
        do something
    {% endif %}

任何人都可以提供帮助。感谢!!!

1 个答案:

答案 0 :(得分:2)

您正在寻找{% ifchanged %}。看看这里:https://docs.djangoproject.com/en/dev/ref/templates/builtins/#ifchanged

相关问题