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

前端 未结 16 1342
北恋
北恋 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:12

    In case anyone is setting a ForeignKey, you can just allow nullable fields without setting a default:

    new_field = models.ForeignKey(model, null=True)
    

    If you already have data stored within the database, you can also set a default value:

    new_field = models.ForeignKey(model, default=)
    

提交回复
热议问题