开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜