码迷,mamicode.com
首页 > 其他好文 > 详细

Django model :add a non-nullable field 'SKU' to product without a default; we can't do that

时间:2016-08-05 00:56:15      阅读:554      评论:0      收藏:0      [点我收藏+]

标签:

You are trying to add a non-nullable field ‘SKU‘ to product without a default; we can‘t do that (the database needs something to populate existing rows).

Please select a fix:

 1) Provide a one-off default now (will be set on all existing rows)

 2) Quit, and let me add a default in models.py

Select an option: 1

Please enter the default value now, as valid Python

The datetime and django.utils.timezone modules are available, so you can do e.g.

timezone.now()

>>> timezone.now()

 

如何还是不断重复上述提示,那么就该model的字段删除,重新再写一次,

然后

python3 manage.py makemigrations

python3 manage.py migrate

..........

 

Django model :add a non-nullable field 'SKU' to product without a default; we can't do that

标签:

原文地址:http://www.cnblogs.com/alan-babyblog/p/5738975.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!