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

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

    You can use method from Django Doc from this page https://docs.djangoproject.com/en/1.8/ref/models/fields/#default

    Create default and use it

    def contact_default():
       return {"email": "to1@example.com"}
    
    contact_info = JSONField("ContactInfo", default=contact_default)
    

提交回复
热议问题