          context = Context(self.get_html_context())
          return template.render(context)
  
  
  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')
  
  
  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'
 
</s> remove     # TODO: handle queries with '' as a legitimate position
 </s> add  </s> remove         encoded = encode_cursor(cursor)
 </s> add         encoded = _encode_cursor(cursor) </s> remove         encoded = encode_cursor(cursor)
 </s> add         encoded = _encode_cursor(cursor) </s> remove                 position = ''
 </s> add                 position = None
          context = Context(self.get_html_context())
          return template.render(context)
  
  


























  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'
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Support for tuple ordering in cursor pagination 
rest_framework/pagination.py