class Incubator(models.Model):
name = models.CharField(max_length=30)
category = models.CharField(max_length=30, blank=True)
acceptanceRate = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True)
funding = models.IntegerField()
programLength = models.DecimalField(max_digits=4, decimal_places=2)
kloutScore = models.IntegerField(blank=True, null=True)
companies = models.ManyToManyField(Company, blank=True)
def __unicode__(self):
return self.name
当我将任何整数字段留空时,我不断收到一条错误消息,
IntegrityError at /admin/incubators/incubator/add/
incubators_incubator.kloutScore may not be NULL
我认为通过设置blank=true和null=true,就可以解决这个问题?
最佳答案
这是因为我在创建数据库后添加了“blank=true”和“null=true”。我必须删除我的数据库,然后删除“syncdb”,然后它就起作用了。
关于django - 完整性错误 - 整数字段不能为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11337123/