title: Bootstrap Carousel Implementation in Django
body: <p>I am trying to implement the twitter bootstrap 3 slideshow into a template, however, I cannot set the flag variable. The first div requires a class of <code>active item</code>, and the rest should just have an <code>item</code> class. How can I best achieve this in a for loop?</p>
  
  <pre><code>{% for review in reviews|slice:":3" %}
      &lt;div class="carousel-inner"&gt;
  
      {% if forloop.counter0|divisibleby:"3" %}
       &lt;div class="active item"&gt;
      {% else %}
      &lt;div class="item"&gt;
      {% endif %}
      &lt;blockquote&gt;
           &lt;p&gt;{{ review.description }}&lt;/p&gt;
      &lt;/blockquote&gt;
      &lt;label&gt;{{ review.business }}&lt;/label&gt;
      &lt;/div&gt;
  {% endfor %}
  </code></pre>
  
  <p>What I have already tried:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/24600885/split-django-queryset-in-template-for-bootstrap-carousel">Split Django Queryset in template for Bootstrap Carousel</a></li>
  <li><a href="https://stackoverflow.com/questions/9202452/implementing-twitter-bootstrap-carousel">Implementing twitter bootstrap carousel v2.3.2</a></li>
  <li><a href="https://stackoverflow.com/questions/25314489/dynamic-carousel-with-django-and-bootstrap">Dynamic carousel with django and bootstrap</a></li>
  </ul>