1👍
Define it inside your model class as follows:
def __unicode__(self):
return self.first_name + self.last_name
0👍
This might be what you are looking for – https://docs.djangoproject.com/en/dev/topics/db/models/#verbose-field-names
- [Answer]-Ajax prevents setting jQuery select value? (Django admin)
- [Answer]-Django form submit not working
- [Answer]-Use of string in if() statement django error: string as left operand, not QuerySet
- [Answer]-Make a query that hits the DB and then make others from it without hitting
0👍
Define the default string representation on the target model:
class Trida(models.Model):
název=models.CharField(max_length=20)
tridni_ucitel=models.ForeignKey(Ucitel, blank=True, null=True)
predmety=models.ForeignKey(Predmety, blank=True, null=True)
class Ucitel(models.Model):
firstname=models.CharField(max_length=20)
lastname=models.CharField(max_length=20)
...
def __unicode__(self):
return u'%s %s' % (self.firstname, self.lastname)
If you are using Python 3, use __str__()
instead of __unicode__()
.
This is covered in the first page of the Django Tutorial: https://docs.djangoproject.com/en/dev/intro/tutorial01/
- [Answer]-Monitor Management Command Execution in Django
- [Answer]-DJango Template – Custom template tags pass 2 variables
- [Answer]-Use HttpResponse with JSON data in this code
- [Answer]-Why replaced div content gone after refresh?
Source:stackexchange.com