add 'symmetrical' argument to OneToOneField('self')
|Reported by:||aldo.deluca@…||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:1 Changed 8 years ago by anonymous
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:2 Changed 8 years ago by anonymous
- Needs documentation set
- Needs tests set
- Patch needs improvement set
comment:3 Changed 8 years ago by serialx
- Triage Stage changed from Unreviewed to Design decision needed
comment:5 Changed 5 years ago by julien
- Component changed from Core framework to Database layer (models, ORM)