I have seen several examples of using select_related to query foriegn key related data in queryset. Including this example. But I want to do it in reverse way as explained below.
class Book(models.Model):
name = models.CharField(max_length=50)
author = models.ForeignKey(Author)
class Author(models.Model):
name = models.CharField(max_length=50)
I have seen queryset to fetch the data while querying the Book because Author is specified in books.Like this
books = Book.objects.all().select_related("author")
But I need to query Author and then get all the books related with it.Is there any way to do that.