{% for p in profiles %}
<div class="result">
{{ p.first_name }}
</div>
{% endfor %}
Suppose I have 1000 of these, in a huge list. How would I make this code appear every 15 times?
<div class="menu">abc</div>
{% for p in profiles %}
<div class="result">
{{ p.first_name }}
</div>
{% endfor %}
Suppose I have 1000 of these, in a huge list. How would I make this code appear every 15 times?
<div class="menu">abc</div>
You can use the forloop.counter
value with a divisibleby
filter in an if
condition. See the documentation here
Use the forloop.counter variable with divisbleby filter.
{% if forloop.counter|divisbleby:"15" %}
<div class="menu">abc</div>
{% endif %}