I have two models that look like this:
class Author(models.Model):
name = models.CharField(max_length=200)
class Book(models.Model):
author = models.ForeignKey('Author', on_delete=models.CASCADE)
isbn_id = models.CharField(max_length=50, null=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
How can I make a query such that:
I get each author with the total number of books created, number of books with an isbn.
Each time a book is created for an author, I can get the last_created, last_modified.
This is an example of the result I am trying to achieve;
s/n| author| no_books_with_isbn| all_books| last_created| last_modified
1. Faye 2 2 ... ....
2. Soya 2 5
3. Jake 6 6
4. Gurj 4 4
5. Zoom 2 10