列表是空的但不应该是

时间:2016-02-10 14:14:59

标签: python django

membership = GroupMembers.objects.filter(profile=profile.id, accepted__isnull=False).values_list('group', flat=True)

当我不使用values_list时,我在成员资格中有一个元素。但我只想拥有一个包含GroupMembers模型的所有属性“group”的列表。所以我了解了values_list。但是,现在这将给我一个空列表。有什么问题?

编辑:

class Profile(models.Model):
    id = models.AutoField(primary_key=True, db_column='profile_id')
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    description = models.TextField(blank=True, null=True, default=None, max_length=500)
    group_set = models.ManyToManyField(Group, through='GroupMembers')
    file_set = models.ManyToManyField(File, blank=True)
    user_code = models.TextField(blank=True, null=True, default=None)

class GroupMembers(models.Model):
        id = models.AutoField(primary_key=True, db_column='group_profile_id')
        group = models.ForeignKey(Group, db_column='group_id')
        profile = models.ForeignKey(Profile, db_column='profile_id')
        rank = models.CharField(max_length=45, null=True, default=None, blank=True)
        invited = models.DateTimeField(auto_now_add=True)
        accepted = models.DateTimeField(null=True, default=None, blank=True)
        rejected = models.DateTimeField(null=True, default=None, blank=True)
        is_admin = models.BooleanField(default=False)

0 个答案:

没有答案