我four <div>
在一個頁面。我想在每個<div>
上顯示25
記錄。我寫了亂碼。它不工作。你能幫我嗎?謝謝關於for循環(模板循環)
<div one > <div two> <div three> <div four>
1 26 51 76
2 27 52 77
3 28 53 78
- - - -
- - - -
25 50 75 100
</div> </div> </div> </div>
這裏是模板代碼。
<div class="fourcolumnswrapper">
<div class="moviescolumn">
{% for movie in movies.object_list %}
<a href="{{ movie.get_absolute_url}}">{{ movie.title }}</a><br/>
<!-- Display first 25 record in one div -->
{% if forloop.counter == 25 %}
</div>
{% endif %}
{% if forloop.counter > 25 and forloop.counter <= 50 %}
<div class="moviescolumn">
{% if forloop.counter == 50 %}
</div>
{% endif %}
{% endif %}
{% if forloop.counter > 50 and forloop.counter < 75 %}
<div class="moviescolumn">
{% if forloop.counter == 75 %}
</div>
{% endif %}
{% endif %}
{% endfor %}
</div>
更新輸出:http://i.imgur.com/zuc8y.png這裏是源代碼generated by view source
。 http://dpaste.org/dxKi8/
你得到什麼樣的輸出? – second
@second http://i.imgur.com/zuc8y.png – Kulbir
代碼比圖片也許更實用...嘗試http://dpaste.com/ – second