Django templates: Group items in Threes

前端 未结 6 559
感情败类
感情败类 2020-12-05 22:24

I have an odd problem with Django. I have a set of objects that Im looping through in a template as you would normally. However, I need to group the items in threes. The lay

6条回答
  •  遥遥无期
    2020-12-05 22:53

    How's about something around these lines:

    {% for p in paintingss %}
        
    whatever
    {% if forloop.counter|divisibleby:"3" %}
    {% endif %} {% endfor %}

    Will this do you good?

提交回复
热议问题