django - 完整性错误 - 整数字段不能为空

标签 django

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/

相关文章:

django - 升级时迁移内置 Django 模型

python - Django:从 django.urls 导入反向; ImportError:没有名为 urls 的模块

javascript - AJAX POST 上的 Django [WinError 10053]

python - Django 注释 json 字段中的特定键

python - Django DLL加载失败: The specified module could not be found

python - 如何在 Django 表单 ChoiceField 中获取选项标签?

django - 用于 Django 1.5 和 Python 3 的 Mongodb ORM

python - 内存泄漏 - gunicorn + django + mysqldb

python - 如何将生成的图表保存在媒体文件夹中

django - 如何从 Django 中的信号处理程序获取 session