Почему Django требует установить значение по умолчанию для MultiPolygonField? - PullRequest
0 голосов
/ 11 марта 2019

, когда я пытаюсь выполнить миграцию моделей с полями Geometry в 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).

Почему я должен установить значение по умолчанию?и как это исправить для мультиполигона?

...