Python 将Django模型字段移动到导致错误迁移的子类的正确方法
我正试图在我的Django模型上实现表面上的noop。现在看起来像Python 将Django模型字段移动到导致错误迁移的子类的正确方法,python,django,django-models,Python,Django,Django Models,我正试图在我的Django模型上实现表面上的noop。现在看起来像 class OrgParent(model.Model): name = models.CharField() organization = models.ForeignKey(...) order = models.IntegerField() class Meta: abstract = True unique_together = (('name', 'or
class OrgParent(model.Model):
name = models.CharField()
organization = models.ForeignKey(...)
order = models.IntegerField()
class Meta:
abstract = True
unique_together = (('name', 'order'),)
ordering = ('order',)
class OrgChild(OrgParent)
other_field = models.CharField()
我想把它压缩成一个模型:
class OrgChild(models.Model)
other_field = models.CharField()
name = models.CharField()
organization = models.ForeignKey(...)
order = models.IntegerField()
class Meta:
abstract = True
unique_together = (('name', 'order'),)
ordering = ('order',)
但是,当我在manage.py makemigrations
上执行此Django(运行1.7,计划很快升级)时,它会创建一个自动迁移,实际上会删除我的整个表
xxxx_auto_xxxxxxx_xxxxx.py:
- Alter unique_together for organizationchild (0 constraint(s))
- Remove field organization from organizationchild
- Delete model OrganizationChild
我想这个新模型的数据库支持将以完全相同的方式工作,因此我实际上不需要迁移。有没有办法忽略迁移?我应该只签入迁移,但删除迁移中的操作吗?是否有首选的Django方法来管理此迁移