when I try to makemigrate models with Geometry fields to postgres DB I face with next message:
You are trying to change the nullable field 'geom' on allotment to non-nullable without a default; we can't do that (the database needs something to populate existing rows).
OK, set default = ' ', or something like 'MULTIPOLIGON (((0. 0. 0. 0. 0.)))' and when I wish to migrate terminal throws this:
..File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/django/contrib/gis/geos/geometry.py", line 697, in __init__ raise ValueError('String input unrecognized as WKT EWKT, and HEXEWKB.') ValueError: String input unrecognized as WKT EWKT, and HEXEWKB.
An examples of my classes with geometry:
class ForestryKeys(models.Model): id = models.IntegerField(primary_key=True) name = models.TextField(blank=True, null=True), geom = models.MultiPolygonField(verbose_name='geo',srid = 4326) class Meta: managed = True verbose_name = 'geo' verbose_name_plural = 'geos'
id = models.IntegerField(primary_key=True) df_names = models.TextField(blank=True, null=True) geom = models.MultiPolygonField(verbose_name='polygs',srid = 4326) forestry_id = models.ForeignKey(ForestryKeys, models.DO_NOTHING, blank=True, null=True) class Meta: managed = True verbose_name = 'ULV' verbose_name_plural = 'ULVs'
Why I have to set default value? and how it do correct for diffrient geometry types?