How to return number of rows in the template

Posted by xRobot on Stack Overflow See other posts from Stack Overflow or by xRobot
Published on 2010-05-20T15:36:31Z Indexed on 2010/05/20 15:40 UTC
Read the original article Hit count: 261

In my view I return all posts of one blog:

    posts = Post.objects.filter(blog=blog)

and pass it to context.

But.. How can I get the number of posts in the template ?

This is my template:

 <h1>Number of posts: {{ ??? }}  </h1>

 {% for post in posts %}

 {{ post.title }}

 {{ post.body }}

 {% endfor %}

© Stack Overflow or respective owner

Related posts about django

Related posts about django-views