summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2014-02-18 10:19:04 +0100
committerClaude Paroz <claude@2xlibre.net>2014-02-18 10:23:30 +0100
commit45edb9d2359c60952fd791616df887eb95f75746 (patch)
tree4742734d9a93d09484660a7523067b6666ef3285 /django
parentfaf6a911ad7357c8dd1defa3be0317a8418febf7 (diff)
Fixed #22057 -- Ensured reverse_lazy can be used in settings
And without causing a circular import. Thanks Akis Kesoglou for the report.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/sql/aggregates.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/django/db/models/sql/aggregates.py b/django/db/models/sql/aggregates.py
index aef8b493bb..ce2968c445 100644
--- a/django/db/models/sql/aggregates.py
+++ b/django/db/models/sql/aggregates.py
@@ -5,16 +5,12 @@ import copy
from django.db.models.fields import IntegerField, FloatField
from django.db.models.lookups import RegisterLookupMixin
+from django.utils.functional import cached_property
__all__ = ['Aggregate', 'Avg', 'Count', 'Max', 'Min', 'StdDev', 'Sum', 'Variance']
-# Fake fields used to identify aggregate types in data-conversion operations.
-ordinal_aggregate_field = IntegerField()
-computed_aggregate_field = FloatField()
-
-
class Aggregate(RegisterLookupMixin):
"""
Default SQL Aggregate.
@@ -61,14 +57,23 @@ class Aggregate(RegisterLookupMixin):
while tmp and isinstance(tmp, Aggregate):
if getattr(tmp, 'is_ordinal', False):
- tmp = ordinal_aggregate_field
+ tmp = self._ordinal_aggregate_field
elif getattr(tmp, 'is_computed', False):
- tmp = computed_aggregate_field
+ tmp = self._computed_aggregate_field
else:
tmp = tmp.source
self.field = tmp
+ # Two fake fields used to identify aggregate types in data-conversion operations.
+ @cached_property
+ def _ordinal_aggregate_field(self):
+ return IntegerField()
+
+ @cached_property
+ def _computed_aggregate_field(self):
+ return FloatField()
+
def relabeled_clone(self, change_map):
clone = copy.copy(self)
if isinstance(self.col, (list, tuple)):