相关疑难解决方法(0)

您试图在没有默认值的情况下向userprofile添加不可为空的字段"new_field"

我知道从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).
Run Code Online (Sandbox Code Playgroud)

这是models.py:

class UserProfile(models.Model):
    user = models.OneToOneField(User)
    website = models.URLField(blank=True)
    new_field = models.CharField(max_length=140)
Run Code Online (Sandbox Code Playgroud)

有什么选择?

python django

85
推荐指数
7
解决办法
12万
查看次数

标签 统计

django ×1

python ×1