  
      def __init__(self, protocol='both', **kwargs):
          self.protocol = protocol.lower()
          self.unpack_ipv4 = (self.protocol == 'both')
          super(IPAddressField, self).__init__(**kwargs)
          validators, error_message = ip_address_validators(protocol, self.unpack_ipv4)
          self.validators.extend(validators)
  
      def to_internal_value(self, data):
          if not isinstance(data, six.string_types):
 
</s> remove         super(PrimaryKeyRelatedField, self).__init__(**kwargs)
 </s> add         super().__init__(**kwargs) </s> remove         super(NullBooleanField, self).__init__(**kwargs)
 </s> add         super().__init__(**kwargs) </s> remove         super(SlugRelatedField, self).__init__(**kwargs)
 </s> add         super().__init__(**kwargs) </s> remove                 self.error_messages['max_length'].format,
                six.text_type)(max_length=self.max_length)
 </s> add                 self.error_messages['max_length'].format, str)(max_length=self.max_length) </s> remove         if isinstance(data, six.text_type) or not hasattr(data, '__iter__'):
 </s> add         if isinstance(data, str) or not hasattr(data, '__iter__'):
        super().__init__(**kwargs)
  
      def __init__(self, protocol='both', **kwargs):
          self.protocol = protocol.lower()
          self.unpack_ipv4 = (self.protocol == 'both')
        super().__init__(**kwargs)
          validators, error_message = ip_address_validators(protocol, self.unpack_ipv4)
          self.validators.extend(validators)
  
      def to_internal_value(self, data):
          if not isinstance(data, six.string_types):
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/fields.py