当向models.py对应类添加一个新字段
password = models.CharField(max_length=20)
之后,执行python3 manage.py makemigrations命令提示以下信息:
You are trying to add a non-nullable field 'password' to userinfo 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) Quit, and let me add a default in models.py
只需要在字段的后面加一个default=""即可:
password = models.CharField(max_length=20,default="")