summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2014-07-25 09:49:51 -0700
committerAndrew Godwin <andrew@aeracode.org>2014-07-25 09:50:17 -0700
commit3268711417b3c67f6eb08bec3f39f2d51186e11b (patch)
tree85c1d1d3655e5c964f9be5ed57c8ba3749ea9076
parente01c565b4777e1546caede74f3f7d5650e30e3ab (diff)
[1.7.x] Fixed #23085: Better error message for PostGIS 1.5/bad custom fields
-rw-r--r--django/db/backends/schema.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/django/db/backends/schema.py b/django/db/backends/schema.py
index 9645c40761..c9052e29d8 100644
--- a/django/db/backends/schema.py
+++ b/django/db/backends/schema.py
@@ -490,7 +490,12 @@ class BaseDatabaseSchemaEditor(object):
old_type = old_db_params['type']
new_db_params = new_field.db_parameters(connection=self.connection)
new_type = new_db_params['type']
- if old_type is None and new_type is None and (old_field.rel.through and new_field.rel.through and old_field.rel.through._meta.auto_created and new_field.rel.through._meta.auto_created):
+ if (old_type is None and old_field.rel is None) or (new_type is None and new_field.rel is None):
+ raise ValueError("Cannot alter field %s into %s - they do not properly define db_type (are you using PostGIS 1.5 or badly-written custom fields?)" % (
+ old_field,
+ new_field,
+ ))
+ elif old_type is None and new_type is None and (old_field.rel.through and new_field.rel.through and old_field.rel.through._meta.auto_created and new_field.rel.through._meta.auto_created):
return self._alter_many_to_many(model, old_field, new_field, strict)
elif old_type is None and new_type is None and (old_field.rel.through and new_field.rel.through and not old_field.rel.through._meta.auto_created and not new_field.rel.through._meta.auto_created):
# Both sides have through models; this is a no-op.