Use Django 1.9. I have two models related to each other, one contains an id and name among other attributes and the other contains its own id along with the id of the first model:
class Televisor(models.Model):
idTelevisor = models.AutoField(primary_key=True)
marca = models.CharField(max_length=45, null=False)
modelo = models.CharField(max_length=45, null=False)
...
class Falla(model.Models):
idFalla = models.AutoField(primary_key=True)
idTelevisor = ForeignKey(Televisor)
...
However, in the admin of django I would like for the second model, the names of the objects to come out using the attributes contained in the first model. Which I have been unable to do with the syntax that I will describe later, since I get an ObjectHasNoAttribute error.
In that case, what is the syntax? For example, I have this syntax, but it causes errors because the attributes do not exist in the second model:
def __unicode__(self):
return '{} {} {}'.format(self.televisor.Marca, self.televisor.Modelo, self.televisor.VarianteModelo)
Greetings and thanks in advance