Django - Caching
You have these models:
How do you optimize a query to get all books with their authors and authors' publishers in the fewest queries?
class Publisher(models.Model):
name = models.CharField(max_length=100)
class Author(models.Model):
name = models.CharField(max_length=100)
publisher = models.ForeignKey(Publisher, on_delete=models.CASCADE)
class Book(models.Model):
title = models.CharField(max_length=100)
author = models.ForeignKey(Author, on_delete=models.CASCADE)How do you optimize a query to get all books with their authors and authors' publishers in the fewest queries?
