1👍
✅
You can use prefetch_related
Parent.objects.filter(children__first=True).prefetch_related('children')
Child.objects.filter(first=True).select_related('parent')
0👍
You have to use the fetch_related method for that and do the lookup the other way around unfortunately.
In this case it should be something like this:
first_children = Child.objects.filter(first=True).select_related('parent')
parents = [c.parent for c in first_children]
Source:stackexchange.com