How do I find all th开发者_运维技巧e Members that bob shares a group with?
class Member(Model):
     name = CharField(max_length=30)
class GroupMember(Model):
     member = ForeignKey(Member)
     group  = ForeignKey(Group)
class Group(Model):
     name = CharField(max_length=30)
Member.objects.filter(group__in=bob.group_set.all()).exclude(pk=bob.pk)
Edit I didn't notice that you didn't have a ManyToMany relationship set up between Member and Group. You'll need to add that:
class Group(Model):
   name = CharField(max_length=30)
   members = ManyToManyField(Member, through='Membership')
now syncdb and it should work.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论