开发者

Getting tag article count

开发者 https://www.devze.com 2023-03-14 13:28 出处:网络
I want to get each tag\'s article count from taggitItem table; I have written the following but it doesn\'t work correctly.

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

精彩评论

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

关注公众号