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
當我離開任何integerfields的空白,我不斷收到一個錯誤,指出,完整性錯誤 - integerfield不能爲null
IntegrityError at /admin/incubators/incubator/add/
incubators_incubator.kloutScore may not be NULL
我想通過把空白=真和空=真,它會解決這個問題?
您是否更新了數據庫以允許該字段在數據庫級別爲空? – imm
使用__python manage.py sqlall __進行檢查,然後在爲孵化器創建表列表中進行驗證,但是您的整數字段沒有「NOT NULL」約束。 –
Rohan
對於任何人來到這個問題尋找如何設置IntegerField(空= True)爲NULL:http://stackoverflow.com/a/6291171/2271127基本上使用無。數據庫會將None轉換爲NULL。 – Gadget