【发布时间】:2017-06-27 07:59:18
【问题描述】:
这就是我想要的。我不是在谈论 forloop.counter。我的情况不是 forloop.counter 因为我需要有条件地增加它。
<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 的新手,并且其中没有视图或模型。你能指导我吗?
标签: django django-templates django-cms