views:

21

answers:

1

I have these 2 models:

genre = (
    ('D', 'Dramatic'),
    ('T', 'Thriller'),
    ('L', 'Love'),
)

class Book(models.Model):


    title = models.CharField(max_length=100)
    genre = models.CharField(max_length=1, choices=genre)


class Author(models.Model):

    user = models.ForeignKey(User, unique=True)
    born = models.DateTimeField('born')    
    book = models.ForeignKey(Book)

I need to retrieve first_name and last_name of all authors of dramatic's books.

How can I do this in django ?

+3  A: 

Like the documentation says...

Author.objects.filter(book__genre='D')
Ignacio Vazquez-Abrams