[Fixed]-Django eager loading in many to many

20👍

Manytomany uses prefetch_related;

FacultyMember.objects.filter(
pk=id,
first_name=first_name,
last_name=last_name
).prefetch_related('project_set').prefetch_related('publication_set')

Refer here https://docs.djangoproject.com/en/1.8/ref/models/querysets/#prefetch-related

Leave a comment