I set up a model with models.PolygonField in geodjango, using postgres as database. I try to import shp into postgres. The problem is, shp (compiled with QGIS) mixes polygon and multipolygon, hence it always fails to do the export because of the constraint check enforce_geotype. So is there a way to clear the constraint, so as to store both multipolygon and polygon type data?
|
|
||||
|
|
|
The SQL to drop the constraint:
Or to alter it to allow both Polygons & MultiPolygons:
These SQL statements could be run from a South migration or an initial-data SQL script. Another option is to make it a Or, override the
|
|||
|
|
|
I know this is old, but I just ran into this issue myself and had problems using the above suggested solutions:
My current solution is explicitly coercing all of my |
|||
|
|
|
longish workaround one could use fromstr()
|
||||
|
|
