[英]Createsuperuser django.db.utils.IntegrityError: NOT NULL constraint failed
I have recently change my model which is a personified model adding fields.我最近更改了我的模型,这是一个添加字段的拟人化模型。 After having done so I remove the file:
完成后,我删除了文件:
'db.sqlite3'
'db.sqlite3'
And launch:并启动:
python manage.py migrate --run-syncdb
The user creation via my application is fine but when I want to create a super user通过我的应用程序创建用户很好,但是当我想创建超级用户时
python manage.py createsuperuser
I get the following error:我收到以下错误:
django.db.utils.IntegrityError: NOT NULL constraint failed: website_dater.latitude
There is a field called latitude in your model named like website which is not taking any null entry.您的模型中有一个名为latitude的字段,名为 like website ,它不采用任何空条目。 Either provide a value of latitude by default or use (null=True,blank=True) in defining that model, Like this :
默认情况下提供纬度值或在定义该模型时使用 (null=True,blank=True),如下所示:
class Website(models.Model):
....
latitude = models.CharField(max_length=250, blank=True, null=True)
# Or
latitude = models.CharField(default='0')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.