(모델 예시) [myapp/models.py]
class Item:
pass
class Item:
name = models.CharField('이름', null=True)
$ ./manage.py makemigrations
Migrations for 'myapp':
myapp/0002_add_item_name.py
- Add field name to item
class Item:
name = models.CharField('이름', null=False) # null=False를 안써도 됨
$ ./manage.py makemigrations
You are trying to change the nullable field 'name' on item to non-nullable 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 with a null value for this column)
2) Ignore for now, and let me handle existing rows with NULL myself (e.g. because you added a RunPython or RunSQL operation to handle NULL values in a previous data migration)
3) Quit, and let me add a default in models.py
Select an option: 2
Migrations for 'myapp':
myapp/0003_alter_item_name.py
- Alter field name on item