Hello all,
in a ViewSet, i prefetch a related model with filtered queryset based on 
some query params:

filter_class = BarFilter
def get_queryset(self):

    queryset = self.queryset
    foo = self.request.query_params.get('foo', None)
    if foo:
        queryset = queryset.prefetch_related(Prefetch('resources', 
queryset=Resource.objects.filter(foo=foo)))
    else:
        queryset = queryset.prefetch_related('resources')
    return queryset


also, in filter class, i wan't to further filter the related models:

buz = django_filters.NumberFilter('resources__buz', lookup_type='gte', 
distinct=True)


but, it seems that this filter ignores views get_queryset, as it applies 
the related search on all related models even if the foo query param exists

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to