def filter_queryset(self, request, queryset, view):
        if 'descendant_of' in request.GET:
            if getattr(queryset, '_filtered_by_child_of', False):
                raise BadRequestError("filtering by descendant_of with child_of is not supported")
            try:
                ancestor_page_id = int(request.GET['descendant_of'])
                assert ancestor_page_id >= 0
            except (ValueError, AssertionError):
                raise BadRequestError("descendant_of must be a positive integer")

            site_pages = pages_for_site(request.site)
            try:
                ancestor_page = site_pages.get(id=ancestor_page_id)
                return queryset.descendant_of(ancestor_page)
            except Page.DoesNotExist:
                raise BadRequestError("ancestor page doesn't exist")

        return queryset
dataset/ETHPy150Open torchbox/wagtail/wagtail/contrib/wagtailapi/filters.py/DescendantOfFilter.filter_queryset/original