Django prefetch_related not being helpful in diminishing queries
myList = [] qs = MyModel.objects.all().prefetch_related(‘m2m_model_set’) for model in qs: k = model.m2m_model_set.all().values_list(‘field’) myList.extend(k) This code represents what I am doing. Why is the line k = model.m2m_model_set.all().values_list(‘field’) causing many queries? How can I fix this problem and do the same without making so many queries? python django performance django-prefetch-related 1 If you further filter, […]