我想根据标签将某些特定文章排除在我的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]
答案 0 :(得分:0)
您尝试过吗:
return Article.published().all().exclude(tags__name="Exclude Article")[:5]