function to get the order key to apply it in the filtered queryset

        :param kwargs: dict: query dict sent by data tables package
        :return: str: order key, which can be used directly in queryset's
          order_by function

def get_order_key(self, **kwargs):
        """
        function to get the order key to apply it in the filtered queryset

        :param kwargs: dict: query dict sent by data tables package
        :return: str: order key, which can be used directly in queryset's
          order_by function
        """
        # get the mapping enumeration class from Meta class
        mapping = self.mapping
        # use the first element in the enumeration as default order column
        order_column = kwargs.get('order[0][column]',
                                  [mapping.keys()[0]])[0]
        order_column = ensure(int, order_column, mapping.keys()[0])
        order = kwargs.get('order[0][dir]', ['asc'])[0]

        order_key = mapping.from_key(order_column).label
        # django orm '-' -> desc
        if order == 'desc':
            order_key = '-' + order_key
        return order_key