Re: Display a value from another table

2009-11-02 Thread Tom Evans
On a Book instance, the 'authors' attribute is a manager, so Tim's examples should read: {% for book in books %} {{ book.name }} {% for author in book.authors.all %} {{ author }} {% endfor %} {% endfor %} or in Python code: book = Book.objects.get(id=42) for auth

Re: Display a value from another table

2009-11-02 Thread Tim Chase
> class Author(models.Model): > name = models.CharField(max_length=100) > title = models.CharField(max_length=3, choices=TITLE_CHOICES) > birth_date = models.DateField(blank=True, null=True) > > def __unicode__(self): > return self.name > > class Book(models.Model): >

Re: Display a value from another table

2009-11-02 Thread Denis Bahati
Here is my model. TITLE_CHOICES = ( ('MR', 'Mr.'), ('MRS', 'Mrs.'), ('MS', 'Ms.'), ) class Author(models.Model): name = models.CharField(max_length=100) title = models.CharField(max_length=3, choices=TITLE_CHOICES) birth_date = models.DateField(blank=True, null=True)

Re: Display a value from another table

2009-11-01 Thread Rishabh Manocha
On Mon, Nov 2, 2009 at 1:43 PM, Denis Bahati wrote: > Hi All, > Am developing an application where by it links two tables author and book, > the id of author is a foreign key to book table. How can i display the name > of the author when am displaying the book list. > > > > I'm not sure how you t