当我尝试将具有“几何”字段的模型迁移到Postgres DB时 几何类的示例:
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'
class DistrForestKeys(models.Model):
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'
等
我面对下一条消息:
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).
为什么必须设置默认值?以及如何正确处理多边形?