我知道从 Django 1.7 开始我不需要使用 South 或任何其他迁移系统,所以我只使用简单的命令 python manage.py makemigrations
但是,我得到的只是这个错误:
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).
这是模型.py:
class UserProfile(models.Model):
user = models.OneToOneField(User)
website = models.URLField(blank=True)
new_field = models.CharField(max_length=140)
什么是选项?
原文由 Irmantas Želionis 发布,翻译遵循 CC BY-SA 4.0 许可协议
您需要提供一个默认值: