multiplate table inheritance subclass with extra OneToOneField relationship to parent class
I have a model which essentially boils down to this:
class Person(models.Model): name = models.TextField()
class MarriedMan(Person): wife = models.OneToOneField(Person, on_delete=models.CASCADE, related_name='husband')
But when I try to make the migration, I get the following error:
django.core.exceptions.ImproperlyConfigured: Add parent_link=True to webapp.MarriedMan.wife.
It seems like Django is automatically promoting my OneToOneField to be the one which holds the reference to the parent class. But that's not what I intended. I want there to be an extra wife relationship in addition to the implicit automatic OneToOneField.
As far as I could tell from the documentation, that's exactly what NOT passing parent_link=True is supposed to signify:
If you want to control the name of the attribute linking back to the parent, you can create your own OneToOneField and set parent_link=True to indicate that your field is the link back to the parent class.
As a workaround I could explicitly define the parent_link relationship plus my own wife relationship, but that doesn't seem to be the correct solution.