      elif isinstance(value, dict):
          template = loader.get_template('rest_framework/admin/dict_value.html')
          context = {'value': value}
          return template.render(context)
      elif isinstance(value, six.string_types):
          if (
              (value.startswith('http:') or value.startswith('https:')) and not
              re.search(r'\s', value)
          ):
              return mark_safe('<a href="{value}">{value}</a>'.format(value=escape(value)))
 
</s> remove         name = six.text_type(value.obj)
 </s> add         name = str(value.obj) </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     elif isinstance(val, six.string_types):
 </s> add     elif isinstance(val, str): </s> remove             if isinstance(value, six.text_type):
 </s> add             if isinstance(value, str):
    elif isinstance(value, str):
      elif isinstance(value, dict):
          template = loader.get_template('rest_framework/admin/dict_value.html')
          context = {'value': value}
          return template.render(context)
    elif isinstance(value, str):
          if (
              (value.startswith('http:') or value.startswith('https:')) and not
              re.search(r'\s', value)
          ):
              return mark_safe('<a href="{value}">{value}</a>'.format(value=escape(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