我正在尝试在模板中显示外键引用值。我的模型如下
class CustomerType(models.Model):
customer_type_id = models.AutoField(primary_key=True)
customer_type_name = models.CharField(max_length=15)
class Prospects(models.Model):
prospect_id = models.AutoField(primary_key=True)
customer_type = models.ForeignKey(CustomerType )
我的查询
prospectList = Prospects.objects.using (settings.DATABASE_CONF).filter (status=1).values
('prospect_id' , 'customer_type')
模板
<td>
{{ prospect.customer_type_id }}
</td>
我只能获得“customer_type_id”,但我想显示“customer_type_name”。怎么做。我尝试了 '__' 选项,但这不起作用。