Django:SQLIte的非空约束失败
下面是我的模型。运行Django:SQLIte的非空约束失败,django,python-3.x,sqlite,Django,Python 3.x,Sqlite,下面是我的模型。运行python manage.py migrate django.db.utils.IntegrityError: NOT NULL constraint failed: app_project.description 模型如下: from django.db import models # Create your models here. class Project(models.Model): title = models.CharField(max_len
python manage.py migrate
django.db.utils.IntegrityError: NOT NULL constraint failed: app_project.description
模型如下:
from django.db import models
# Create your models here.
class Project(models.Model):
title = models.CharField(max_length=100)
description = models.TextField(max_length=2000, blank=True, default='')
progress = models.FloatField(default=0)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return self.title
class Task(models.Model):
project = models.ForeignKey(Project, on_delete=models.CASCADE)
title = models.CharField(max_length=100)
severity = models.SmallIntegerField(default=0)
open_date = models.DateTimeField()
close_date = models.DateTimeField()
status = models.SmallIntegerField(default=0)
def __str__(self):
return self.title
我在Django 1.10上更改为:
description = models.TextField(max_length=2000, blank=True, null=True, default='')
以允许数据库中的值为空
请参阅null和blank之间的差异,并将更改为:
description = models.TextField(max_length=2000, blank=True, null=True, default='')
以允许数据库中的值为空
请参见null和blank以及