          # Adding Transform() to the SQL placeholder if the value srid
          # is not equal to the field srid.
          if value_srid is None or value_srid == f.srid:
              placeholder = '%s'
          elif f.geom_type == 'RASTER' and isinstance(value, six.string_types):
              placeholder = '%s((%%s)::raster, %s)' % (self.transform, f.srid)
          else:
              placeholder = '%s(%%s, %s)' % (self.transform, f.srid)
  
          if hasattr(value, 'as_sql'):
 
</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         if gtype == 'RASTER' and (value is None or isinstance(value, six.string_types + (dict, self._klass))):
 </s> add         if gtype == 'RASTER' and (value is None or isinstance(value, (str, dict, self._klass))): </s> remove         elif value is None or isinstance(value, six.string_types + (six.memoryview,)):
 </s> add         elif value is None or isinstance(value, (str, memoryview)): </s> remove         elif isinstance(srs_input, six.string_types):
 </s> add         elif isinstance(srs_input, str): </s> remove         if value and isinstance(value, six.string_types):
 </s> add         if value and isinstance(value, str):
        elif f.geom_type == 'RASTER' and isinstance(value, str):
          # Adding Transform() to the SQL placeholder if the value srid
          # is not equal to the field srid.
          if value_srid is None or value_srid == f.srid:
              placeholder = '%s'
        elif f.geom_type == 'RASTER' and isinstance(value, str):
              placeholder = '%s((%%s)::raster, %s)' % (self.transform, f.srid)
          else:
              placeholder = '%s(%%s, %s)' % (self.transform, f.srid)
  
          if hasattr(value, 'as_sql'):
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/contrib/gis/db/backends/postgis/operations.py