看看这些:
South migration for multi-table inheritance
和
Using south to refactor a Django model with inheritance
两者均基于已弃用的南方'应用。有没有人尝试成功使用django 1.7+迁移来重构模型以获得继承?
EG。从:
class OrderItem(TimeStampedMixin, models.Model):
...
要:
class BaseOrderItem(models.Model):
pass
class OrderItem(TimeStampedMixin, BaseOrderItem):
...
当我运行makemigration orders
时,魔法并没有回填基础模型:
You are trying to add a non-nullable field 'baseorderitem_ptr' to orderitem 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
这似乎是一项要完成的任务。