1
Try this
Author.objects.all().annotate(s=Min('book__pubdate')).order_by('s')
When if some author dont have books
Author.objects.exclude(book__pubdate__isnull=True).annotate(s=Min('book__pubdate')).order_by('s')
Source:stackexchange.com
1
Try this
Author.objects.all().annotate(s=Min('book__pubdate')).order_by('s')
When if some author dont have books
Author.objects.exclude(book__pubdate__isnull=True).annotate(s=Min('book__pubdate')).order_by('s')