class Motivation(models.Model): def __unicode__(self): # Python 3: def __str__(self): return '%s - %s' % (self.score, self.description)
score = models.CharField(max_length=100) description = models.CharField(max_length=300) insert_date = models.DateTimeField(auto_now_add=True) #insert date update_date = models.DateTimeField(auto_now=True) #last updated date 2013/11/21 Chantal Rosmuller <crosm1...@gmail.com> > Hi, > > I'm pretty new to Django soi excuse me if this is a stupid question, but > here we go. > > I have the following model: > > class Motivation(models.Model): > def __unicode__(self): # Python 3: def __str__(self): > return self.score > > score = models.CharField(max_length=100) > description = models.CharField(max_length=300) > insert_date = models.DateTimeField(auto_now_add=True) #insert date > update_date = models.DateTimeField(auto_now=True) #last updated > date > > and another model with a foreign key to the first one: > > class PerformanceAnimal(models.Model): > def __unicode__(self): # Python 3: def __str__(self): > return u'%s' % self.animal > > training_session = models.ForeignKey('Training') > animal = models.ForeignKey('animals.Animal') > state_of_mind = models.CharField(max_length=200, blank=True) > motivation = models.ForeignKey('behaviour.Motivation') > > In the admin panel the foreign key select field shows the score (like it's > supposed to), but I would like it to show score, description > > How do I go about that? > > Thanks for your help. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/db2ae4c7-4842-4e9d-afdc-376e2a0ad51b%40googlegroups.com > . > For more options, visit https://groups.google.com/groups/opt_out. > -- Rafael E. Ferrero -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJJc_8V3xNN6vfpSxtbkZMNaU0D70FVhZ-96wyUEOxaOQ8FHeg%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.