def _build_prefetch_queryset(
        self,
        name,
        original_field,
        field,
        filters,
        requirements
    ):
        related_queryset = getattr(original_field, 'queryset', None)

        if callable(related_queryset):
            related_queryset = related_queryset(field)

        source = field.source or name
        # Popping the source here (during explicit prefetch construction)
        # guarantees that implicitly required prefetches that follow will
        # not conflict.
        required = requirements.pop(source, None)

        if self.DEBUG:
            # push prefetches
            prefetches = self._prefetches
            self._prefetches[source] = {}
            self._prefetches = self._prefetches[source]

        queryset = self._filter_queryset(
            serializer=field,
            filters=filters.get(name, {}),
            queryset=related_queryset,
            requirements=required
        )

        if self.DEBUG:
            # pop back
            self._prefetches = prefetches

        return queryset
Applies prefetches to a queryset.
dataset/ETHPy150Open AltSchool/dynamic-rest/dynamic_rest/filters.py/DynamicFilterBackend._build_prefetch_queryset