You need to output something like this:

<div class="scrollable"><div class="items"> <div><img src="1" alt=""/><img src="2" alt=""/><img src="3" alt=""/></div> <div><img src="4" alt=""/><img src="5" alt=""/><img src="6" alt=""/></div> <div><img src="7" alt=""/><img src="8" alt=""/><img src="9" alt=""/></div> </div></div> 

From the array of the form ['1', '2', '3', '4', '5', '6', '7', '8', '9']. How best to do this, given that the number of elements in the array can be anything (from 1 to infinity).

Thank!

    1 answer 1

    Helped

     <div> {% for item in items %} <img src="{{item}}" /> {% if forloop.counter|divisibleby:"3" %} </div> <div> {% endif %} {% endfor %} </div> 
    • one
      A good decision, note that this filter can be used in this case. - l0ki