          return OrderedDict(fields)
  
      def __new__(cls, name, bases, attrs):
          attrs['_declared_fields'] = cls._get_declared_fields(bases, attrs)
          return super(SerializerMetaclass, cls).__new__(cls, name, bases, attrs)
  
  
  def as_serializer_error(exc):
      assert isinstance(exc, (ValidationError, DjangoValidationError))
  
 
</s> remove class DynamicListRoute(object):
 </s> add class DynamicListRoute: </s> remove                 path = urlparse.urlparse(link.url).path
 </s> add                 path = parse.urlparse(link.url).path </s> remove class DynamicDetailRoute(object):
 </s> add class DynamicDetailRoute: </s> remove             for name, value in six.iteritems(headers):
 </s> add             for name, value in headers.items(): </s> remove             path = urlparse.urlparse(link.url).path
 </s> add             path = parse.urlparse(link.url).path
        return super().__new__(cls, name, bases, attrs)
          return OrderedDict(fields)
  
      def __new__(cls, name, bases, attrs):
          attrs['_declared_fields'] = cls._get_declared_fields(bases, attrs)
        return super().__new__(cls, name, bases, attrs)
  
  
  def as_serializer_error(exc):
      assert isinstance(exc, (ValidationError, DjangoValidationError))
  
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/serializers.py