相关疑难解决方法(0)

Django模型:共同的祖先传承和迁移

我以为我会通过开发一个大型商业应用程序以获得乐趣来与Django稍微提升我的python游戏.我看到需要一种共同的祖先方法来模拟继承,并试图在官方文档的基础上实现它.但是,我不断收到这个非常烦人的消息,我不知道该怎么办.

  • Dj版本: Django 1.7
  • Py版本: Python 3.4.2

信息

$ python manage.py makemigrations
Run Code Online (Sandbox Code Playgroud)
You are trying to add a non-nullable field 'businessentity_ptr' to business without a default; we can't do that (the database needs something to populate existing rows).

Please select a fix:
 1) Provide a one-off default now (will be set on all existing rows)
 2) Quit, and let me add a default in models.py
Run Code Online (Sandbox Code Playgroud)

Models.py

class BusinessEntity(models.Model):
    title = models.CharField(max_length=180)

    def __str__(self):
        return …
Run Code Online (Sandbox Code Playgroud)

python django inheritance django-models

1
推荐指数
1
解决办法
1641
查看次数

标签 统计

django ×1

django-models ×1

inheritance ×1

python ×1