[Django]-How to put an class on specific (first element) inside loop?

6👍

{% for slide in slides_list %}
<div class="item{% if forloop.first %} active{% endif %}">
  <img src="{{slide.imagem.url}}" alt="{{slide.imagem.titulo}}" />
  <div class="carousel-caption slider">
    <h2>{{slide.titulo}}</h2>
    <p>{{slide.mensagem}}</p>
  </div><!--/carousel-caption-->
</div><!--/item-->
{% endfor %}

The for tag and the forloop variable docs

Leave a comment