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.

Am I missing something?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9ce76375-d614-4fb6-a38d-27e28465b687%40googlegroups.com.

Reply via email to