I'm playing with the book/author django documentation.
Is there a way to get books from author grouped by kinds in an array agg? (pgsql)
The following query is correct but I need information from authors table.
Books.objects.values('kind').annotate(rating_min=Min('rating'),.. Etc.
Can I get author's books rating range grouped by kind ?
Author.objects.values('book__kind'). annotate(rating_min=Min('book__rating'))
Author.objects.annotate(rated_books=ArrayAgg('book'),...?
Expecting something like
author.rated_books =[
{'kind': 'fantasy', 'rating_min' : 2,
'rating_max' : 5, 'total' : 6},
]
Any idea to combine both?