Getting tag article count
I want to get each tag's article count from taggitItem table; I have written the following but it doesn't work correctly.
article_content_type = ContentType.objects.get_fo开发者_JAVA技巧r_model(Article)
articles = TaggedItem.objects.filter(content_type = article_content_type).annotate(count = Count('tag'))
Please help.
article_count = TaggedItem.objects.filter(content_type = article_content_type).count()
Perhaps it is even better not to use the TaggedItem class, but do it via the Article class.
精彩评论