diff options
author | Dan McGee <dan@archlinux.org> | 2011-11-03 23:30:16 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-11-03 23:30:16 -0500 |
commit | 0db2830b8fda4d898a184a31f3375c10f3cc4083 (patch) | |
tree | fed2700088e1f03ffcd9af906184d81f199955fc /main | |
parent | 19c2841f20653fd3c59f73fdb16f7f7b1ea15434 (diff) |
Make maintainer lookup on todo lists fast
This is rather sick to look at. Sorry, Django gives me no other choice.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'main')
-rw-r--r-- | main/models.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/main/models.py b/main/models.py index db456c20..caf36be0 100644 --- a/main/models.py +++ b/main/models.py @@ -460,12 +460,17 @@ class Todolist(models.Model): def __unicode__(self): return self.name + _packages = None + @property def packages(self): - # select_related() does not use LEFT OUTER JOIN for nullable ForeignKey - # fields. That is why we need to explicitly list the ones we want. - return TodolistPkg.objects.select_related( - 'pkg__repo', 'pkg__arch').filter(list=self).order_by('pkg') + if not self._packages: + # select_related() does not use LEFT OUTER JOIN for nullable + # ForeignKey fields. That is why we need to explicitly list the + # ones we want. + self._packages = TodolistPkg.objects.select_related( + 'pkg__repo', 'pkg__arch').filter(list=self).order_by('pkg') + return self._packages @property def package_names(self): |