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
> 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):
>
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)
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
4 matches
Mail list logo