[Django]-Performing a right join in django (take 2)

3👍

The accepted answer to that linked question is, quite simply, wrong –
as a comment there notes.

select_related only works for forward relationships. For backwards ones, you need prefetch_related:

Student.objects.all().prefetch_related('attendance_set')

Note, this will do two separate queries.

Leave a comment