私は次の-簡略化された-モデルを持っています:
class User(models.Model):
following = models.ManyToManyField("self", through='Following', symmetrical=False)
class Following(models.Model):
from_user = models.ForeignKey(User, related_name='from_user')
to_user = models.ForeignKey(User, related_name='to_user')
status = models.IntegerField()
ステータスは、保留中の場合は0、フォロー中の場合は1です。ユーザーをユーザーにします。フォローしているユーザーのすべてを取得したい
できます
user.following.all()
ユーザーがフォローしているすべてのユーザーを取得する(保留中の関係または実際にフォローしている)
また
Following.objects.filter(from_user=user, status=1)
ユーザーユーザーと本当の友情で以下のすべてのオブジェクトを取得するには
しかし、userおよびstatus = 1のすべてのUserオブジェクトを取得するにはどうすればよいですか?道が見つからないようです
ありがとうございました !