以下のコードが current_count 変数に値を追加していない理由を説明してください。また、django バージョン 1.3 を使用しています。以下のコードは、次の出力を提供します。
0
"画像"
10
"画像"
10
"画像"
. . .
「画像」とは、実際の画像が表示されていることを意味します。
私が欲しいのは「4つの画像のみを表示する」です。
{% with current_count=0 %}
{% for row in people|slice:":4" %}
{% if row %}
{% for event in row %}
{% if current_count < 4 %}
{{current_count}}
<div class="latest-photos-image-box">
<a href="{{ event.get_absolute_url }}"><img src="{{ event.mainthumb.url }}" alt="{{ event.title }}" /></a>
</div>
{% endif %}
{{ current_count|add:"1" }}
{% endfor %}
{% endif %}
{% endfor %}
{% endwith %}