[Django]-Many to many field django add the relationship both way

4👍

By default, many-to-many relationships on self are symmetrical. If you don’t want this, set symmetrical to False:

followings = models.ManyToManyField('self', blank=True, symmetrical=False)

See the docs

3👍

Just set related_name=”followed_by” for the many to many field. That would assign the reverse mapping to followed_by

followings = models.ManyToManyField('self', blank=True, symmetrical=False, related_name='followed_by')

Leave a comment