def prep_search_value(self, term, lookup_type):

        # We avoid making changes that the Django ORM can already do for us
        multi_terms = None

        if lookup_type == "in":
            in_bits = re.split(r',\s*', term)
            if len(in_bits) > 1:
                multi_terms = in_bits
            else:
                term = None

        if lookup_type == "range":
            range_bits = re.split(r'\s*-\s*', term)
            if len(range_bits) == 2:
                multi_terms = range_bits
            else:
                term = None

        if multi_terms:
            return filter(None, (self.prep_search_value(multi_term, lookup_type) for multi_term in multi_terms))

        model_field = self.model_field_class()
        try:
            term = model_field.get_prep_value(term)
        except:
            term = None

        return term
An implementation of im2col based on some fancy indexing
dataset/ETHPy150Open pivotal-energy-solutions/django-datatable-view/datatableview/columns.py/Column.prep_search_value--crossover with--dataset/ETHPy150Open dnlcrl/PyFunt/pyfunt/layers/im2col.py/im2col_indices