You are trying to add a non-nullable field 'new_field' to userprofile without a default

前端 未结 16 1361
北恋
北恋 2020-11-30 19:27

I know that from Django 1.7 I don\'t need to use South or any other migration system, so I am just using simple command python manage.py makemigrations

16条回答
  •  盖世英雄少女心
    2020-11-30 20:07

    If you are fine with truncating the table of the model in question, you can specify a one-off default value of None in the prompt. The migration will have superfluous default=None while your code has no default. It can be applied just fine because there's no data in the table anymore which would require a default.

提交回复
热议问题