      def run_validation(self, data=empty):
          # We force empty strings to None values for relational fields.
          if data == '':
              data = None
          return super(RelatedField, self).run_validation(data)
  
      def get_queryset(self):
          queryset = self.queryset
          if isinstance(queryset, (QuerySet, Manager)):
              # Ensure queryset is re-evaluated whenever used.
 
</s> remove         if data == '' or (self.trim_whitespace and six.text_type(data).strip() == ''):
 </s> add         if data == '' or (self.trim_whitespace and str(data).strip() == ''): </s> remove         return super(RelatedField, self).get_attribute(instance)
 </s> add         return super().get_attribute(instance) </s> remove         if value is None or value is '':
 </s> add         if value is None or value == '': </s> remove class BaseUniqueForValidator(object):
 </s> add class BaseUniqueForValidator: </s> remove             data = urlparse.urlparse(data).path
 </s> add             data = parse.urlparse(data).path
        return super().run_validation(data)
      def run_validation(self, data=empty):
          # We force empty strings to None values for relational fields.
          if data == '':
              data = None
        return super().run_validation(data)
  
      def get_queryset(self):
          queryset = self.queryset
          if isinstance(queryset, (QuerySet, Manager)):
              # Ensure queryset is re-evaluated whenever used.
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/relations.py