我知道從Django 1.7我不需要使用南或任何其他遷移系統,所以我只是使用簡單的命令python manage.py makemigrations
您正在試圖添加一個不可空的字段'new_field'到用戶配置文件沒有默認
但是,我得到的是這樣的錯誤:
You are trying to add a non-nullable field 'new_field' to userprofile without a default;
we can't do that (the database needs something to populate existing rows).
這裏是models.py:
class UserProfile(models.Model):
user = models.OneToOneField(User)
website = models.URLField(blank=True)
new_field = models.CharField(max_length=140)
有什麼選擇?
我想補充說,當你改變現有的表格時,而不是當你創建一個新的表格時,會發生問題。 – 2017-05-18 10:48:00