

def get_query_set(self, request=None):
    qs = self.root_query_set.clone()
    try:
        (self.filter_specs, self.has_filters, remaining_lookup_params, use_distinct) = self.get_filters(request)
        for filter_spec in self.filter_specs:
            new_qs = filter_spec.queryset(request, qs)
            if (new_qs is not None):
                qs = new_qs
    except ValueError:
        remaining_lookup_params = self._lookup_param_1_3()
    try:
        qs = qs.filter(**remaining_lookup_params)
    except (SuspiciousOperation, ImproperlyConfigured):
        raise
    except Exception as e:
        raise IncorrectLookupParameters(e)
    ordering = self.get_ordering(request, qs)
    qs = qs.order_by(*ordering)

    def construct_search(field_name):
        if field_name.startswith('^'):
            return ('%s__istartswith' % field_name[1:])
        elif field_name.startswith('='):
            return ('%s__iexact' % field_name[1:])
        else:
            return ('%s__icontains' % field_name)
    if (self.search_fields and self.query):
        orm_lookups = [construct_search(str(search_field)) for search_field in self.search_fields]
        for bit in self.query.split():
            or_queries = [Q(**{
                orm_lookup: bit,
            }) for orm_lookup in orm_lookups]
            qs = qs.filter(reduce(operator.or_, or_queries))
    return qs

dataset/ETHPy150Open MongoEngine/django-mongoengine/django_mongoengine/mongo_admin/views.py DocumentChangeList.get_query_set/original