      return b64encode(querystring.encode('ascii')).decode('ascii')
  
  
  class CursorPagination(BasePagination):
      # TODO: handle queries with '' as a legitimate position
      # Support case where ordering is already negative
      # Support tuple orderings
      cursor_query_param = 'cursor'
      page_size = api_settings.PAGINATE_BY
      invalid_cursor_message = _('Invalid cursor')
 
</s> remove Cursor = namedtuple('Cursor', ['offset', 'reverse', 'position'])


def decode_cursor(encoded):
    try:
        querystring = b64decode(encoded.encode('ascii')).decode('ascii')
        tokens = urlparse.parse_qs(querystring, keep_blank_values=True)
        offset = int(tokens['offset'][0])
        reverse = bool(int(tokens['reverse'][0]))
        position = tokens['position'][0]
    except (TypeError, ValueError):
        return None

    return Cursor(offset=offset, reverse=reverse, position=position)


def encode_cursor(cursor):
    tokens = {
        'offset': str(cursor.offset),
        'reverse': '1' if cursor.reverse else '0',
        'position': cursor.position
    }
    querystring = urlparse.urlencode(tokens, doseq=True)
    return b64encode(querystring.encode('ascii')).decode('ascii')


 </s> add  </s> remove                 position = ''
 </s> add                 position = None </s> remove                 position = ''
 </s> add                 position = None </s> remove             queryset = queryset.order_by('-' + self.ordering)
 </s> add             queryset = queryset.order_by(_reverse_ordering(self.ordering))
      return b64encode(querystring.encode('ascii')).decode('ascii')
  
  
  class CursorPagination(BasePagination):

      # Support case where ordering is already negative
      # Support tuple orderings
      cursor_query_param = 'cursor'
      page_size = api_settings.PAGINATE_BY
      invalid_cursor_message = _('Invalid cursor')
keep keep keep keep replace keep keep keep keep keep
 Support for tuple ordering in cursor pagination 
rest_framework/pagination.py