def get_query_dict(self, **kwargs):
        """
        function to generate a filter dictionary, in which the key is the
        keyword used in django filter function in string form, and the value is
        the searched value.

        :param kwargs:dict: query dict sent by data tables package
        :return: dict: filtering dictionary
        """
        total_cols = ensure(int, kwargs.get('total_cols', [0])[0], 0)
        mapping = self.mapping
        filter_dict = defaultdict(dict)

        # set up the starter, since sometimes we start the enumeration from '1'
        starter = mapping.keys()[0]
        for i in range(starter, total_cols):
            key = 'columns[{index}]'.format(index=i)
            if kwargs.get(key + '[searchable]', [0])[0] != 'true':
                continue
            search_value = kwargs.get(key + '[search][value]', [''])[0].strip()
            if not search_value:
                continue
            enum_item = mapping.from_key(i)
            filter_obj = enum_item.extra
            if type(filter_obj) is tuple and len(filter_obj) == 2:
                filter_func, filter_key = filter_obj
                filter_dict[filter_func][filter_key] = search_value
            elif type(filter_obj) is str:
                filter_dict['filter'][filter_obj] = search_value
            else:
                raise ValueError("Invalid filter key.")
        return filter_dict
def get_query_dict ( self , ** kwargs ) : total_cols = ensure ( int , kwargs . get ( 'total_cols' , [ 0 ] ) [ 0 ] , 0 ) mapping = self . mapping filter_dict = defaultdict ( dict ) starter = mapping . keys ( ) [ 0 ] for i in range ( starter , total_cols ) : key = 'columns[{index}]' . format ( index = i ) if kwargs . get ( key + '[searchable]' , [ 0 ] ) [ 0 ] != 'true' : continue search_value = kwargs . get ( key + '[search][value]' , [ '' ] ) [ 0 ] . strip ( ) if not search_value : continue enum_item = mapping . from_key ( i ) filter_obj = enum_item . extra if type ( filter_obj ) is tuple and len ( filter_obj ) == 2 : filter_func , filter_key = filter_obj filter_dict [ filter_func ] [ filter_key ] = search_value elif type ( filter_obj ) is str : filter_dict [ 'filter' ] [ filter_obj ] = search_value else : raise ValueError ( "Invalid filter key." ) return filter_dict
function to generate a filter dictionary, in which the key is the
        keyword used in django filter function in string form, and the value is
        the searched value.

        :param kwargs:dict: query dict sent by data tables package
        :return: dict: filtering dictionary