Login

custom template filter to check if list contains any non-empty element

Author:
doniyor
Posted:
September 4, 2014
Language:
Python
Version:
Not specified
Tags:
list custom-template-tag custom-filters
Score:
0 (after 0 ratings)

in template:

{% if not list|seeany %} list empty {% else %}

1
2
3
@register.filter
def seeany(list):
    return any(list)

More like this

Comments

Please login first before commenting.