18👍
Use list|length
. |
indicates that you will use a filter. The size of the list is
{{ list|length }}
- [Django]-Django Password Generator
- [Django]-">", "<", ">=" and "<=" don't work with "filter()" in Django
- [Django]-Does django with mongodb make migrations a thing of the past?
10👍
{% if your_list %}
{{ your_list|length }}
{% endif %}
Just remember that if your_list is a property it will be tigger on this line, so if you make dynamic list that is created each time you ask for it and you want to for
later you will trigger it twice;
- [Django]-How to group by AND aggregate with Django
- [Django]-Storing an Integer Array in a Django Database
- [Django]-Sending images using Http Post
5👍
Just a little update in case someone ends up here. As pointed in the comments, if you have a QuerySet, now it’s possible to get the length with:
{{ your_list.count }}
Hope it helps!
- [Django]-Django MultiValueDictKeyError error, how do I deal with it
- [Django]-Retrieving parameters from a URL
- [Django]-Effects of changing Django's SECRET_KEY
Source:stackexchange.com