1๐
โ
By default, a self referential ManyToManyField
is symmetrical. See the following in the docs:
โฆ
ManyToManyField
is assumed to be symmetrical โ that is, if I am your
friend, then you are my friend.If you do not want symmetry in many-to-many relationships with self,
set symmetrical to False. This will force Django to add the descriptor
for the reverse relationship, allowing ManyToManyField relationships
to be non-symmetrical.
You can achieve it by adding:
models.ManyToManyField("self", symmetrical=False)
๐คHamish
- [Answered ]-Django Model.objects.all() and Model.objects.get(pk=?) return two different results
- [Answered ]-How to open a Popup window which contains a graph written in javascript?
- [Answered ]-Should I use advance GeoDjango libraries for one simple calculation?
Source:stackexchange.com