django - show the length of a queryset in a template

前端 未结 4 954
走了就别回头了
走了就别回头了 2020-12-15 16:02

In my html file, how can I output the size of the queryset that I am using (for my debugging purposes)

I\'ve tried

{{ len(some_queryset) }}
         


        
4条回答
  •  再見小時候
    2020-12-15 16:15

    Just to highlight @Yuji'Tomita'Tomita comment above as a separate answer:

    There is a filter called length to call len() on anything.

    So you could use:

    {{ some_queryset|length }}
    

提交回复
热议问题