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

前端 未结 7 1490
南旧
南旧 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:59

    If you tried myList|length and myList|length_is and its not getting desired results, then you should use myList.count

提交回复
热议问题