I have a list in my Django template. I want to do something only if the size of the list is greater than zero.
I have tried myList|length and m
myList|length
m
If you're using a recent Django, changelist 9530 introduced an {% empty %} block, allowing you to write
{% for athlete in athlete_list %} ... {% empty %} No athletes {% endfor %}
Useful when the something that you want to do involves special treatment for lists that might be empty.