[Answered ]-How to create a one-sided relationship with ManyToManyField('self')

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

1๐Ÿ‘

You need to make the relation asymmetrical.

Leave a comment