From 02609ac05e608857016b0edf666b96bf22c225e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Tue, 29 Jan 2019 19:56:43 +0200 Subject: [PATCH] This query can return duplicates, add distinct() --- hc/accounts/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hc/accounts/models.py b/hc/accounts/models.py index a7fe9ab4..dc2f9604 100644 --- a/hc/accounts/models.py +++ b/hc/accounts/models.py @@ -115,7 +115,8 @@ class Profile(models.Model): is_owner = models.Q(owner=self.user) is_member = models.Q(member__user=self.user) - return Project.objects.filter(is_owner | is_member).order_by("name") + q = Project.objects.filter(is_owner | is_member) + return q.distinct().order_by("name") def checks_from_all_projects(self): """ Return a queryset of checks from projects we have access to. """