0
這就是我想要的。我不是在談論forloop.counter。我的情況不是forloop.counter,因爲我需要有條件地增加它。如何在django中聲明,初始化和遞增變量模板
<div class="row text-left">
/////some counter=0
{% for article in article_list %}
/////{% if counter == 4 %}
</div>
<div class="row text-left">
{% endif %}
{% if article.published %}enter code here
/////// counter++
{% include "aldryn_newsblog/includes/general-article.html" %}
{% endif %}
{% empty %}
<p>{% trans "No items available" %}</p>
{% endfor %}
</div>
爲什麼你認爲你需要這樣做?爲什麼不在視圖中排除article_list中未發佈的文章? –
由於我是django cms的新手,並且沒有視圖或模型。你能指導我嗎? –