From 829ebbd416e7b5c4a963635fca4a19e205af98c5 Mon Sep 17 00:00:00 2001 From: Stephen Burrows Date: Mon, 27 Jun 2011 14:38:52 -0400 Subject: [PATCH] Pre-fetching the contentreference content may have been premature optimization. Switched to a simple fetch, as it seems to run slightly faster. --- philo/templatetags/containers.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/philo/templatetags/containers.py b/philo/templatetags/containers.py index 5a2d158..fdcd82c 100644 --- a/philo/templatetags/containers.py +++ b/philo/templatetags/containers.py @@ -29,17 +29,7 @@ class ContainerContext(object): def get_references(self): if not hasattr(self, '_references'): references = self.page.contentreferences.all() - self._references = {} - contents = {} - for c in references: - ct = ContentType.objects.get_for_id(c.content_type_id) - self._references[(c.name, ct)] = c - contents.setdefault(ct, {})[c.content_id] = c - - for ct in contents: - objs = ct.model_class().objects.filter(pk__in=contents[ct]) - for obj in objs: - contents[ct][obj.pk].content = obj + self._references = dict((((c.name, ContentType.objects.get_for_id(c.content_type_id)), c) for c in references)) return self._references -- 2.20.1