检索多对多关系的目标对象

Retrieve the target object of many to many relationship

我正在通过关系创建多对多关系来创建 follow/follower 关系

用户 -> 关系 -> 用户

我想检索特定用户之后的所有用户对象,但目前我所能做的就是检索关系对象的查询集。

答案是:

User.objects.filter(to_relationships__user=self)
                                    ^^

双下划线允许您跨关系查询