我有三个模型项目,成员,用户
class Project
members = ManyToManyField(User, through="Member")
class User
#...user model...
class Member
project = ForeignKey(Project)
user = ForeignKey(User)
isAdmin = BooleanField(default=False)
如果我想得到一个项目(p)的所有用户对象,我可以做 p.members。但是如何轻松获取项目的所有管理员(用户对象)?
Member.filter(project=p, isAdmin=True) # this gets all the admin member objects
# how to convert this to user objects?