我有两个模型:
class PlayerPermissionGroup(models.Model):
player = models.ForeignKey(Player)
name = models.CharField(max_length=200)
class PlayerPermissionGroupMember(models.Model):
permission_group = models.ForeignKey(PlayerPermissionGroup)
user = models.ForeignKey(User)
目前,要获得权限组中的所有成员,我会这样做:
getMembers(group):
group_member_ids = (PlayerPermissionGroupMember.objects.filter(permission_group=group)
.values_list('user__id'))
return User.objects.filter(pk__in=group_member_ids)
有没有更好/更清洁的方法来做到这一点?