Get count of list items that meet a condition with Jinja2

后端 未结 1 1195

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 th

相关标签:
1条回答
  • 2020-12-11 21:44

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

    {{ my_list|selectattr('foo')|list|length }}
    
    0 讨论(0)
提交回复
热议问题