Skip to content

Instantly share code, notes, and snippets.

@sdklab007
Forked from nix1947/dynamic rows loading
Created April 16, 2020 09:36
Show Gist options
  • Save sdklab007/ad353091e6b5a25d392a0758df9c4c4b to your computer and use it in GitHub Desktop.
Save sdklab007/ad353091e6b5a25d392a0758df9c4c4b to your computer and use it in GitHub Desktop.
dynamically populating rows and columns of bootstrap in django template
<div class="container">
{% for project in projects %}
{% if forloop.counter0|divisibleby:3 %} <div class="row text-center"> {% endif %}
<div class="col-md-4" onclick="window.location.href='{% url 'club:robotics_detail' project.id %}'" style="cursor: pointer">
<div class="card">
<img src="http://placehold.it/300X150" alt="">
<div class="card-content">
<br>
<h4>Project {{ forloop.counter }}</h4>
<hr>
<h3>{{ project.project_name }}</h3>
<p>{{ project.project_summary }}</p>
<br>
</div><!-- card content -->
</div><!-- card -->
</div><!-- col-md-4 -->
{% if forloop.counter|divisibleby:3 or forloop.last %}</div><!-- row closing --><hr>{% endif %}
{% endfor %}
</div><!-- container -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment