我有疑问:
articles = Article.objects.filter(Q(owner=request.user)|Q(group__user=request.user))
但这向我显示了两次文章(所有者=用户和文章编辑组中的用户)。
楷模:
class ProfileGroup(models.Model):
user = models.ManyToManyField(user)
name = models.CharField(max_length=100)
class Article(models.Model):
title = models.CharField(max_length=200)
text = models.TextField()
group = models.ForeignKey(ProfileGroup)
owner = models.ForeignKey(user)
如何仅获取非重复文章?