Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は持っている
Foo<=> FooGroup<=>Bar
Foo
FooGroup
Bar
ここで<=>、ManyToMany フィールドを表します。
<=>
Foo特定のBarインスタンスのすべての を取得するにはどうすればよいですか?
関係があなたの構造に非常によく似ている認証モデルの例を次に示します: ユーザー <=> グループ <=> パーミッション
from django.contrib.auth import models models.Permission.objects.filter(group__user=models.User.objects.get(username="webmaster"))
あなたの例では:
Foo.objects.filter(foogroup__bar=barinstance)