Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django access the length of a list within a template

Simple question. I have a list in my template and want to output the length of the list. Do I have to calculate this in my view and hand it over via my context?

<p>the size of the list is {{??}}</p>  {% for element in list %} <p>element.Name</p> {% end for %} 
like image 980
RParadox Avatar asked Oct 30 '12 12:10

RParadox


1 Answers

Use length filter:

{{ some_list|length }} 
like image 91
K Z Avatar answered Oct 01 '22 01:10

K Z