Many to many field django add the relationship both way

后端 未结 2 715
半阙折子戏
半阙折子戏 2021-01-22 16:15

I\'m trying to do a function that allow a user to follow another one. the problem is when I\'m adding a new user to the \"followings\" the user that follow another user is also

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-22 16:50

    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

提交回复
热议问题