Django values_列表给出id而不是valu

2024-04-23 11:08:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个查询集:

Organisation.objects.values_list('first_parent', flat=True).distinct()

它给我的结果是[1,2],我需要组织名称,但当我需要时:

^{pr2}$

它给了我这些组织的名字。这里怎么了?在

我的组织模式:

class Organisation(User):
    organisation_name = models.CharField(max_length=200)
    first_parent = models.ForeignKey('Parent', related_name="first", blank=True, null=True)

def __unicode__(self):
    return self.username

Tags: nameself名称trueobjectsmodels名字list