Hi everyone. I’ve started to refactor some legacy code and having some difficulties with Model Multi-Table Inheritance on existing model.
Let’s say I have a parent class Item:
class Item(models.Model):
brand = models.CharField(null=True, blank=True)
model = models.CharField(null=True, blank=True)
category = models.CharField(ItemCategory, null=True, blank=True)
I have a child class Phone:
class Phone(Item):
serial_number = models.CharField()
price = models.PositiveIntegerField()
For a transition period I’ve allowed Item fields to be null=True and blank=True for a later manual population. However during a migration call I receive it is impossible to add a non-nullable field 'item_ptr' to phone without specifying a default.. I understand a nature of this warning as django doesn’t know where to link item_ptr which hides under the hood and links to Item model with OneToOne relation. So I have a dummy Item instance I want to use for linking but how to point the Item id/pk on the console with choosen option 1 as it doesn’t recognize raw int as pk. Is it possible overall or the way is to manipulate with migrations manually?
Thanks for a help in advance.