I have a ForeignKeyField in model number one that displays a __unicode__self.name.
I want to use the same unicode in the second model, but everytime I try to do that it's says I need to encode it, I've been trying to solve this by reading Django docs but I can't figure out how.
Here's the code:
class Viaje(models.Model):
cliente = models.ForeignKey(Cliente)
fecha = models.CharField(max_length=244, blank=True)
origen = models.CharField(max_length=244, blank=True)
destino = models.CharField(max_length=244, blank=True)
tracto_numero = models.CharField(max_length=244, blank=True)
def __unicode__(self):
return self.cliente
Try this:
def __unicode__(self):
return unicode(self.cliente)