summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2013-11-27 12:56:33 +0000
committerAndrew Godwin <andrew@aeracode.org>2013-11-27 12:56:33 +0000
commit4fcfc31865240d635c6e13e1f71ed52c0f6bd72c (patch)
tree099ae704c07eb6187f6548c4d943137ec553bf18
parent96dd48c83f429688629b866f8fc64e1a4f3249f3 (diff)
Add gis deconstruct() method (this does not make schema work)
-rw-r--r--django/contrib/gis/db/models/fields.py13
-rw-r--r--django/db/backends/schema.py2
2 files changed, 14 insertions, 1 deletions
diff --git a/django/contrib/gis/db/models/fields.py b/django/contrib/gis/db/models/fields.py
index 6dc2ee23b9..b5cdc72c29 100644
--- a/django/contrib/gis/db/models/fields.py
+++ b/django/contrib/gis/db/models/fields.py
@@ -105,6 +105,19 @@ class GeometryField(Field):
super(GeometryField, self).__init__(**kwargs)
+ def deconstruct(self):
+ name, path, args, kwargs = super(GeometryField, self).deconstruct()
+ # Always include SRID for less fragility; include others if they're
+ # not the default values.
+ kwargs['srid'] = self.srid
+ if self.dim != 2:
+ kwargs['dim'] = self.dim
+ if self.spatial_index != True:
+ kwargs['spatial_index'] = self.spatial_index
+ if self.geography != False:
+ kwargs['geography'] = self.geography
+ return name, path, args, kwargs
+
# The following functions are used to get the units, their name, and
# the spheroid corresponding to the SRID of the GeometryField.
def _get_srid_info(self, connection):
diff --git a/django/db/backends/schema.py b/django/db/backends/schema.py
index 96b0c7f697..8040252f2c 100644
--- a/django/db/backends/schema.py
+++ b/django/db/backends/schema.py
@@ -110,7 +110,7 @@ class BaseDatabaseSchemaEditor(object):
params = []
# Check for fields that aren't actually columns (e.g. M2M)
if sql is None:
- return None
+ return None, None
# Work out nullability
null = field.null
# If we were told to include a default value, do so