def assemble_query(self, terms, search_fields):
        """
        Returns a query, that is a combination of Q objects. That combination
        aims to search keywords within a model by testing the given search
        fields.
        """
        queries = []
        for term in terms:
            or_query = None
            for field in search_fields:
                q = Q(**{'%s__%s' % (field, 'icontains'): term})
                if or_query is None:
                    or_query = q
                else:
                    or_query = or_query | q

            queries.append(or_query)
        return queries


# SearchField classes
dataset/ETHPy150Open mayan-edms/mayan-edms/mayan/apps/dynamic_search/classes.py/SearchModel.assemble_query/original