From 5360d7d3d96828905dd92245faf1bec4cd6ffbc1 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 30 Jan 2010 16:18:40 -0600 Subject: Fix todolist bug with select_related() Hey, what do you know? Using a relational DB in a non-relational way can come back to bite you. Go foreign keys! Signed-off-by: Dan McGee --- main/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main/models.py b/main/models.py index 71b9e181..7a3496a0 100644 --- a/main/models.py +++ b/main/models.py @@ -303,7 +303,10 @@ class Todolist(models.Model): @property def packages(self): - return TodolistPkg.objects.select_related().filter(list=self).order_by('pkg') + # TODO: bug here, because we do foreign keys all wrong the join query fucks up when it + # can't find a foreign key that is missing values, e.g. maintainer == 0. + # Once this is fixed, we can remove the depth argument. + return TodolistPkg.objects.select_related(depth=1).filter(list=self).order_by('pkg') @property def package_names(self): -- cgit v1.2.3-55-g3dc8