如何在Django RSS Feed中按标签排除特定内容

时间:2018-12-27 12:04:18

标签: django django-models django-views

我想根据标签将某些特定文章排除在我的Feed中。

在以下情况下,我想排除所有标记为排除文章的文章。

model.py

tags = models.ManyToManyField(Tag, blank=True, related_name='tagged')

feed.py

def items(self, item):
    return Article.published().all().exclude(tags__name=["Exclude Article"])[:5]

1 个答案:

答案 0 :(得分:0)

您尝试过吗:

return Article.published().all().exclude(tags__name="Exclude Article")[:5]