From 32c04357a87e3727a34f8c5e6ec0114d1fbbb303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anssi=20K=C3=A4=C3=A4ri=C3=A4inen?= Date: Sat, 30 Nov 2013 23:10:15 +0200 Subject: [PATCH] Avoid OrderedDict creation on lookup aggregate check --- django/db/models/sql/query.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index e6667bf26b..bffdd55105 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1064,9 +1064,10 @@ class Query(object): Solve the lookup type from the lookup (eg: 'foobar__id__icontains') """ lookup_splitted = lookup.split(LOOKUP_SEP) - aggregate, aggregate_lookups = refs_aggregate(lookup_splitted, self.aggregates) - if aggregate: - return aggregate_lookups, (), aggregate + if self._aggregates: + aggregate, aggregate_lookups = refs_aggregate(lookup_splitted, self.aggregates) + if aggregate: + return aggregate_lookups, (), aggregate _, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta()) field_parts = lookup_splitted[0:len(lookup_splitted) - len(lookup_parts)] if len(lookup_parts) == 0: