[Answer]-Django v1.6 – using cycle tag twice in a single loop

1πŸ‘

βœ…

{% cycle %} template tag can’t be multi-line. Join in to the single line.

But anyway your code will not work – {{ variable }} will not be expanded in the {% cycle %} tag. You should use {% if %} tag here:

{% if forloop.counter0|divisibleby:"11" %}
   <img src="/static/placeholder.gif" data-src="/media/{{item.picture}}"
           data-src-retina="/media/{{item.picture}}" alt="{{item.name}}">
{% else %}
   <img src="/static/placeholder.gif" data-src="/media/{{item.picture_small}}"
           data-src-retina="/media/{{item.picture_small}}" alt="{{item.name}}">
{% endif %}
πŸ‘€catavaran

Leave a comment