  
          return dictionary.get(self.field_name, empty)
  
      def to_internal_value(self, data):
          if isinstance(data, six.text_type) or not hasattr(data, '__iter__'):
              self.fail('not_a_list', input_type=type(data).__name__)
          if not self.allow_empty and len(data) == 0:
              self.fail('empty')
  
          return [
 
</s> remove         if isinstance(data, (six.text_type, Mapping)) or not hasattr(data, '__iter__'):
 </s> add         if isinstance(data, (str, Mapping)) or not hasattr(data, '__iter__'): </s> remove         if isinstance(data, six.text_type) and len(data) > self.MAX_STRING_LENGTH:
 </s> add         if isinstance(data, str) and len(data) > self.MAX_STRING_LENGTH: </s> remove                 self.error_messages['min_value'].format,
                six.text_type)(min_value=self.min_value)
 </s> add                 self.error_messages['min_value'].format, str)(min_value=self.min_value) </s> remove         if isinstance(data, bool) or not isinstance(data, six.string_types + six.integer_types + (float,)):
 </s> add         if isinstance(data, bool) or not isinstance(data, (str, int, float,)): </s> remove         super(IPAddressField, self).__init__(**kwargs)
 </s> add         super().__init__(**kwargs)
        if isinstance(data, str) or not hasattr(data, '__iter__'):
  
          return dictionary.get(self.field_name, empty)
  
      def to_internal_value(self, data):
        if isinstance(data, str) or not hasattr(data, '__iter__'):
              self.fail('not_a_list', input_type=type(data).__name__)
          if not self.allow_empty and len(data) == 0:
              self.fail('empty')
  
          return [
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