summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJason Myers <jason@jasonamyers.com>2013-11-03 07:19:25 -0600
committerJason Myers <jason@jasonamyers.com>2013-11-03 07:19:25 -0600
commit4f151da1e5e9bf527548a5737d9cd314e3abc68e (patch)
tree6ba849758c7c34cdf593ad6e699ad420b7ce57c1 /django
parent6f070273856720b1192af534f37622a9c42525b9 (diff)
parentf40f90d63b4be295269b5f0de5f919be22daba5c (diff)
Merging in master
Signed-off-by: Jason Myers <jason@jasonamyers.com>
Diffstat (limited to 'django')
-rw-r--r--django/contrib/gis/db/models/sql/aggregates.py6
-rw-r--r--django/db/models/sql/aggregates.py4
-rw-r--r--django/forms/models.py6
3 files changed, 14 insertions, 2 deletions
diff --git a/django/contrib/gis/db/models/sql/aggregates.py b/django/contrib/gis/db/models/sql/aggregates.py
index f8f3ed1eb4..c0a7d894eb 100644
--- a/django/contrib/gis/db/models/sql/aggregates.py
+++ b/django/contrib/gis/db/models/sql/aggregates.py
@@ -1,7 +1,11 @@
-from django.db.models.sql.aggregates import Aggregate
+from django.db.models.sql import aggregates
+from django.db.models.sql.aggregates import * # NOQA
from django.contrib.gis.db.models.fields import GeometryField
+__all__ = ['Collect', 'Extent', 'Extent3D', 'MakeLine', 'Union'] + aggregates.__all__
+
+
class GeoAggregate(Aggregate):
# Default SQL template for spatial aggregates.
sql_template = '%(function)s(%(field)s)'
diff --git a/django/db/models/sql/aggregates.py b/django/db/models/sql/aggregates.py
index 0e1794e0a9..8542a330c6 100644
--- a/django/db/models/sql/aggregates.py
+++ b/django/db/models/sql/aggregates.py
@@ -5,6 +5,10 @@ import copy
from django.db.models.fields import IntegerField, FloatField
+
+__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()
diff --git a/django/forms/models.py b/django/forms/models.py
index 71da43390c..32f0f043ae 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -134,7 +134,11 @@ def model_to_dict(instance, fields=None, exclude=None):
data[f.name] = []
else:
# MultipleChoiceWidget needs a list of pks, not object instances.
- data[f.name] = list(f.value_from_object(instance).values_list('pk', flat=True))
+ qs = f.value_from_object(instance)
+ if qs._result_cache is not None:
+ data[f.name] = [item.pk for item in qs]
+ else:
+ data[f.name] = list(qs.values_list('pk', flat=True))
else:
data[f.name] = f.value_from_object(instance)
return data