Django: You are trying to add a non-nullable field 'name' to mainnav without a default; we

错误原因:

语句中缺少默认值

class Main(models.Model):
    img = models.CharField(max_length=255)
    name = models.CharField(max_length=64)
    trackid = models.IntegerField(default=1)

    class Meta:
        abstract = True

解决方案:

在语句中添加任意的默认值,之后再执行ORM迁移指令:

class Main(models.Model):
    img = models.CharField(max_length=255, default='1')
    name = models.CharField(max_length=64, default='1')
    trackid = models.IntegerField(default=1)

    class Meta:
        abstract = True

 

上一篇:pandas_profiling


下一篇:如何在mysql中输入中文