add 'symmetrical' argument to OneToOneField('self')
|Reported by:||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Cc:||Triage Stage:||Design decision needed|
|Has patch:||no||Needs documentation:||yes|
|Needs tests:||yes||Patch needs improvement:||yes|
I would like to see a new feature on one-to-one relationship.
It would be good if OneToOneField had a 'symmetrical' argument to make this relationship bidirectional.
This could be available only for self one-to-one relationships.
An example model :
class Person(models.Model): name=models.CharField(max_length=100) spouse=models.OneToOneField('self',symmetrical=True) best_friend=models.OneToOneField('self',symmetrical=False)
John is necessarily his spouse's spouse but he may not be his best friend's best friend.
The same feature has already been added to many-to-many relationships.
Thanks to Django developers.
Change History (7)
comment:2 Changed 9 years ago by
|Patch needs improvement:||set|