How can I check the size of a collection within a Django template?

前端 未结 7 1529
南旧
南旧 2020-12-12 21:31

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

7条回答
  •  感动是毒
    2020-12-12 21:58

    Collection.count no bracket

    {% if request.user.is_authenticated %}
    {{wishlists.count}}
    {% else %}0{% endif %}
    

提交回复
热议问题