Django templates problem — {% if object|length > 4 %} raises TemplateDoesNotExist: 500.html

comparison, django-templates, filter

Solution

This is a very old question. Since then, newer versions of Django support operators in if-statement out of the box, so the following code will work just fine:

{% if fotosList|length > 4 %}

{% endif %}

Problem

I have the following in my template. ``` {% 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>&#9660;</span></a> {% endif %} </div> {% endif %} {% endfor %} {% endblock %} ``` And it raises TemplateDoesNotExist: 500.html. If i write simple `{{ fotoList|length }}` it works okay.

Original source