[Answered ]-Django prefetch_related fields with nested select_related fields

1👍

To improve your prefetch, you can do select_related within TeamMember like this:

from django.db.models import Prefetch

Team.objects.prefetch_related(
    Prefetch(
        "team_members",
        queryset=TeamMembers.objects.select_related("employee__user")
    )
)

Leave a comment