#NEWLINE# @ register . as_tag #NEWLINE# def blog_categories( * args ) : #NEWLINE# #INDENT# '\n    Put a list of categories for blog posts into the template context.\n    ' #NEWLINE# posts = BlogPost . objects . published ( ) #NEWLINE# categories = BlogCategory . objects . filter ( blogposts__in = categories ) #NEWLINE# return list ( categories . annotate ( post_count = Count ( 'blogposts' ) ) )