  
  @register.filter
  def format_value(value):
      if getattr(value, 'is_hyperlink', False):
          name = six.text_type(value.obj)
          return mark_safe('<a href=%s>%s</a>' % (value, escape(name)))
      if value is None or isinstance(value, bool):
          return mark_safe('<code>%s</code>' % {True: 'true', False: 'false', None: 'null'}[value])
      elif isinstance(value, list):
          if any([isinstance(item, (list, dict)) for item in value]):
 
</s> remove     elif isinstance(value, six.string_types):
 </s> add     elif isinstance(value, str): </s> remove     elif isinstance(val, six.string_types):
 </s> add     elif isinstance(val, str): </s> remove     return six.text_type(value)
 </s> add     return str(value) </s> remove         if output_format is None or isinstance(value, six.string_types):
 </s> add         if output_format is None or isinstance(value, str): </s> remove             if isinstance(value, six.text_type):
 </s> add             if isinstance(value, str):
        name = str(value.obj)
  
  @register.filter
  def format_value(value):
      if getattr(value, 'is_hyperlink', False):
        name = str(value.obj)
          return mark_safe('<a href=%s>%s</a>' % (value, escape(name)))
      if value is None or isinstance(value, bool):
          return mark_safe('<code>%s</code>' % {True: 'true', False: 'false', None: 'null'}[value])
      elif isinstance(value, list):
          if any([isinstance(item, (list, dict)) for item in value]):
keep keep keep keep replace keep keep keep keep keep
 Dropped Python 2 compatibility. (#6615)

Thanks to Jon Dufresne (@jdufresne) for review.

Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
Co-authored-by: Rizwan Mansuri <Rizwan@webbyfox.com> 
rest_framework/templatetags/rest_framework.py