【发布时间】:2019-07-23 09:25:53
【问题描述】:
我正在构建一个仪表板,其中空白内容具有不同的视图,因此用户不会查看空白区域。
它适用于没有 if 块的 for 循环,例如
{% for dashboard in dashboard_list %}
some content
{% empty %} no data {% endfor %}
现在
{% for todo in todo_list %}
{% if todo.complete %}{% else %} some content
{% endif %} {% empty %} content when its empty {% endfor %}
它不工作并且不显示“无数据”
【问题讨论】:
-
确保您拥有
dashboard_list而不是没有。此外,如果你有 todo_list 条件,其中你有dashboard_list的空块
标签: django python-3.x for-loop django-templates