I have few models in 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
Now, when I try to add a new record for Third model in my Django admin, my <select> box is populated with second_name values. How can I display a concatenated string of different values from both ‘parent’ tables, e.g. first_name + first_value + second_name + second_value?
Just update the
unicodemethod ofsecondModel: