title: How to make dynamic content display across a grid using Django with Bootstrap?
body: <p>I'm working on a Django project with a homepage similar to StackOverflow's: it displays snippets of incoming user-generated content in a single main column. However, I'd like those content snippets to display across rows of 3 filling up the homepage (think [Pinterest pinboard page][2] or a grid layout blog).</p>
  
  <p>I'm using Bootstrap's grid system, but realized I don't know the right combination of Python/Django template magic + Bootstrap to get that incoming content to populate across a grid. Can someone spell this out for me?</p>
  
  <p>I want...</p>
  
  <pre><code>            {% for question in questions.paginator.page %}
              {% question_list_item question %}
              {% endfor %}
  </code></pre>
  
  <p>...to have the repeating effect of</p>
  
  <pre><code>&lt;div class="container"&gt;
       &lt;div class="row clearfix"&gt;
            &lt;div class="col-md-4"&gt;
                  item 1
            &lt;/div&gt;
            &lt;div class="col-md-4"&gt;
                  item 2
            &lt;/div&gt;
            &lt;div class="col-md-4"&gt;
                  item 3
            &lt;/div&gt;
       &lt;/div&gt;
       &lt;div class="row clearfix"&gt;
            &lt;div class="col-md-4"&gt;
                  item 1
            &lt;/div&gt;
            &lt;div class="col-md-4"&gt;
                  item 2
            &lt;/div&gt;
            &lt;div class="col-md-4"&gt;
                  item 3
            &lt;/div&gt;
       &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Update:</strong> I was able to get this working (with a little column-count variation for responsiveness) using the following, but I'm a beginner so please let me know if there's a better solution.</p>
  
  <pre><code>                    &lt;div class="row"&gt;
                          {% for question in questions.paginator.page %}
                          &lt;div class="col-lg-3 col-sm-6 col-xs-12"&gt;
                              {% question_list_item question %}
                          &lt;/div&gt;
                          {% if forloop.counter|divisibleby:4 %}
                      &lt;/div&gt;
                      &lt;div class="row"&gt;
                          {% endif %}
                          {% endfor %}
                      &lt;/div&gt;
  </code></pre>
  
  <p>Thank you!</p>