count gabarit django 1

count gabarit django

#in template you can use the filter length on your model post
{{ posts|length }} 

Here is what the above code is Doing:
1. We’re using the | (pipe) character to apply a filter to a variable.
2. In this case, we’re using the length filter, which returns the number of items in a list.
3. We’re applying the filter to the posts variable, which contains a list of our blog posts.
4. The result of the filter is displayed in the template.

Similar Posts