              if field.remote_field and isinstance(field.remote_field, models.ManyToManyRel):
                  model = field.remote_field.model
                  if hasattr(model._default_manager, 'get_by_natural_key'):
                      def m2m_convert(value):
                          if hasattr(value, '__iter__') and not isinstance(value, six.text_type):
                              return model._default_manager.db_manager(db).get_by_natural_key(*value).pk
                          else:
                              return force_text(model._meta.pk.to_python(value), strings_only=True)
                  else:
                      def m2m_convert(v):
 
</s> remove                             if hasattr(field_value, '__iter__') and not isinstance(field_value, six.text_type):
 </s> add                             if hasattr(field_value, '__iter__') and not isinstance(field_value, str): </s> remove         elif f.geom_type == 'RASTER' and isinstance(value, six.string_types):
 </s> add         elif f.geom_type == 'RASTER' and isinstance(value, str): </s> remove                 not isinstance(self.remote_field.model, six.string_types) and
 </s> add                 not isinstance(self.remote_field.model, str) and </s> remove         if isinstance(self.remote_field.through, six.string_types) or not self.remote_field.through._meta.managed:
 </s> add         if isinstance(self.remote_field.through, str) or not self.remote_field.through._meta.managed: </s> remove         if not issubclass(type(s), six.string_types):
 </s> add         if not issubclass(type(s), str):
                        if hasattr(value, '__iter__') and not isinstance(value, str):
              if field.remote_field and isinstance(field.remote_field, models.ManyToManyRel):
                  model = field.remote_field.model
                  if hasattr(model._default_manager, 'get_by_natural_key'):
                      def m2m_convert(value):
                        if hasattr(value, '__iter__') and not isinstance(value, str):
                              return model._default_manager.db_manager(db).get_by_natural_key(*value).pk
                          else:
                              return force_text(model._meta.pk.to_python(value), strings_only=True)
                  else:
                      def m2m_convert(v):
keep keep keep keep replace keep keep keep keep keep
 Refs #23919 -- Removed six.<various>_types usage

Thanks Tim Graham and Simon Charette for the reviews. 
django/core/serializers/python.py