Did you find any solution?

On Friday, October 18, 2019 at 2:12:21 AM UTC+5:30, Brian Maissy wrote:
>
> 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/98d79af3-b830-43bf-beb1-b739addae9cfo%40googlegroups.com.

Reply via email to