使用 django-tagging 检索特定查询集的标签

发布于 2024-08-06 07:03:44 字数 372 浏览 1 评论 0原文

我正在使用 django 标记,并尝试检索特定查询集的标签列表。这就是我得到的:

tag      = Tag.objects.get(name='tag_name')
queryset = TaggedItem.objects.get_by_model(Article, tag)
tags     = Tag.objects.usage_for_queryset(queryset, counts=True)

“queryset”适当地返回许多已用标签“tag_name”标记的文章,但是当我尝试检索该查询集的所有标签时,“tags”返回所有内容的完整列表该模型的标签。

其他人以前遇到过这个问题,还是这是 django 标记中的一个错误?

I'm using django-tagging, and am trying to retrieve a list of tags for a specific queryset. Here's what I've got:

tag      = Tag.objects.get(name='tag_name')
queryset = TaggedItem.objects.get_by_model(Article, tag)
tags     = Tag.objects.usage_for_queryset(queryset, counts=True)

"queryset" appropriately returns a number of articles that have been tagged with the tag 'tag_name', but when I attempt to retrieve all of the tags for that queryset, "tags" returns a complete list of all tags for that model.

Anyone else run into this before, or is this a bug in django-tagging?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹏半生如梦愿梦如真 2024-08-13 07:03:44

这似乎是 django 标记中的一个错误。补丁已经写好了,但是还没有提交到主干。在此处查找补丁:

http://code.google.com /p/django-tagging/issues/detail?id=44

This appears to be a bug in django-tagging. A patch has been written, but it has not yet been committed to trunk. Find the patch here:

http://code.google.com/p/django-tagging/issues/detail?id=44

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文