[Answered ]-Django assertionerror: assert token.contents == 'endif' in template?

2👍

✅

The syntax of else is not correct:

{% else sort_by == "vehicle_year" %}

Replace it with just {% else %}.

0👍

You can’t put a condition on an else clause. As in normal Python, if you have a further condition, you need to use elif.

{% if sort_by == "last_updated" %}
   ...
{% elif sort_by == "vehicle_year" %}
   ...
{% else %}
   ...
{% endif %}

Leave a comment