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

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

..........

 

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