tat*_*ata 9 comparison filter django-templates
我的模板中有以下内容.
{% block content %}
{% for album in albumsList %}
{% if fotosList %}
<div class="photoalbum-wrapper">
<h3>{{ album.title }}</h3>
<ul class="photoalbum">
{% for foto in fotosList %}<li>item</li>{% endfor %}
</ul>
{% if fotosList|length > 4 %}
<a href="#" class="trigger">?????? <span>▼</span></a>
{% endif %}
</div>
{% endif %}
{% endfor %}
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
它引发了TemplateDoesNotExist:500.html.
如果我写{{ fotoList|length }}得很简单就行了.
Mar*_*mro 11
这是一个非常古老的问题.由于Django的较新版本支持if-statement中的运算符开箱即用,因此以下代码可以正常工作:
{% if fotosList|length > 4 %}
{% endif %}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16648 次 |
| 最近记录: |