I have 2 app: authors_app and books_app
authors_app.models:
class Author(models.Model):
name = models.CharField(max_length=250, unique=True)
books_app.models:
class Book(models.Model):
author = models.ManyToManyField(Author, related_name='authors')
Authors_app Views.py
class AuthorBio(DetailView):
model = Author
template_name = 'author-bio.html'
Problem
I need to get all the book published by the author. In my template I try:
{% for book in author.books.all %}
...
{% endfor %}
But this doesn't work
Question
How can I get all the books by the author