django - Why is the Prefetch object being ignored in prefetch_related? -
using django 1.7:
my queryset looks this:
return super(employeeviewset, self).get_queryset()\ .filter(status__deleted_flag=false, **filter_kwargs)\ .prefetch_related('phone_number_set', 'email_address_set', 'street_address_set', prefetch('file_set', employeefile.objects.active().select_related('content_type')))\ .order_by('last_name', 'first_name')
djdt shows prefetch query executed
select ••• "employees_employeefile" inner join "employees_employeefiletype" on ("employees_employeefile"."content_type_id" = "employees_employeefiletype"."id" ) ("employees_employeefile"."deleted_at" null , "employees_employeefile"."owner_id" in (53, 81, ...)) order "employees_employeefile"."created_at" desc
then djdt shows each employee getting requeried same list of files
select ••• "employees_employeefile" ("employees_employeefile"."owner_id" = 53 , "employees_employeefile"."deleted_at" null) order "employees_employeefile"."created_at" desc
they queries same me, , modelmanager method being used select same 1 (employeefile.objects.active())
vs employee.file_set.active()
also, tried removing select_related('content_type')
in case problem
Comments
Post a Comment