@register.as_tag
def blog_authors(*args):
 blog_posts = BlogPost.objects.published()
 authors = User.objects.filter(blogposts__in=blog_posts)
 return list(authors.annotate(post_count=Count(u'blogposts')))

@ register . as_tag def blog_authors ( * args ) : blog_posts = BlogPost . objects . published ( ) authors = User . objects . filter ( blogposts__in = blog_posts ) return list ( authors . annotate ( post_count = Count ( u'blogposts' ) ) )
put a list of authors for blog posts into the template context .