我在 Django 中有几个模型:
from django.db import models
class First(models.Model):
first_name = models.CharField('First Name', max_length=100)
first_value = models.IntegerField('Value')
def __unicode__(self):
return self.first_name
class Second(models.Model):
first_ref = models.ForeignKey(First)
second_name = models.CharField('Second Name', max_length=100)
second_value = models.IntegerField('Second Value')
def __unicode__(self):
return self.second_name
class Third(models.Model):
second_ref = models.ForeignKey(Second)
third_name = models.CharField('Third Name', max_length=100)
third_value = models.IntegerField('Third Value')
def __unicode__(self):
return self.third_name
现在,当我尝试Third
在我的 Django 管理员中为模型添加新记录时,我的<select>
框中填充了second_name
值。如何显示两个“父”表中不同值的串联字符串,例如first_name + first_value + second_name + second_value
?