Skip to content

Instantly share code, notes, and snippets.

@nix1947
Created February 11, 2017 03:45
Show Gist options
  • Save nix1947/c765513702e76b5b665d146a72307946 to your computer and use it in GitHub Desktop.
Save nix1947/c765513702e76b5b665d146a72307946 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 -->
@HazimAdel101
Copy link

HazimAdel101 commented Feb 2, 2024

I did not work in my code at the first place,
but GPT is there for help made the needed modifications.
Thanks a million

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment