我有一個由Django生成的日曆,並使用Bootstrap進行了樣式化。 這裏是Django模板代碼:每四次迭代修改Django循環
<div class="content">
{% for month in period.get_months %}
<div class="col-md-3">
<div class="row row-centered">
<button class="btn btn-custom active" href="{% url "month_calendar" calendar.slug %}{% querystring_for_date month.start 2 %}">{{month.name}}</button>
</div>
<div>
{% month_table calendar month "small" %}
</div>
</div>
{% endfor %}
</div>
現在,由於月份有不同的數週,他們具有不同的高度,我想避免這樣的:
我從this answer理解最好的解決方案是使用clearfix
。
那麼,我該如何修改我的模板中的for循環,以便Django每四個項目插入一個額外的行<div class="clearfix"></div>
?
你見過['divisibleby'(https://docs.djangoproject.com/en/1.10/ref/templates/builtins/#divisibleby)過濾? –