Skip to content Skip to sidebar Skip to footer

Get Count Of List Items That Meet A Condition With Jinja2

I have a list of dictionaries where each dict has a boolean entry. I want to display the items that are True, along with the count of those items. I'm using the selectattr filter,

Solution 1:

There is a list filter that will transform a generator into a list. So:

{{ my_list|selectattr('foo')|list|length }}

Post a Comment for "Get Count Of List Items That Meet A Condition With Jinja2"