数据库存在数据,models模型变更生成迁移文件提示
It is impossible to add a non-nullable field ‘xxx’ to app without specifying a default. This is because the database needs something to populate existing rows.
并给出两种选项:
- Provide a one-off default now (will be set on all existing rows with a null value for this column)
提供一次性默认值 - Quit and manually define a default value in models.py.
手动给models中该字段增加默认值
1、输入1,表示选择第一项,然后输入一次性默认值,char类型需要带 ‘’
2、更改models
给该字段新增 default=“xxx” 表示默认值
或null=True 表示允许为空