          self.encoding = encoding
  
          Driver.ensure_registered()
  
          if isinstance(ds_input, six.string_types):
              # The data source driver is a void pointer.
              ds_driver = Driver.ptr_type()
              try:
                  # OGROpen will auto-detect the data source type.
                  ds = capi.open_ds(force_bytes(ds_input), self._write, byref(ds_driver))
 
</s> remove         if isinstance(ds_input, six.string_types):
 </s> add         if isinstance(ds_input, str): </s> remove         if isinstance(ds_input, six.string_types) and json_regex.match(ds_input):
 </s> add         if isinstance(ds_input, str) and json_regex.match(ds_input): </s> remove         form_data['categories'] = [six.text_type(self.c1.id), six.text_type(self.c2.id)]
 </s> add         form_data['categories'] = [str(self.c1.id), str(self.c2.id)] </s> remove     if isinstance(data_source, six.string_types):
 </s> add     if isinstance(data_source, str): </s> remove             if isinstance(to, six.string_types):
 </s> add             if isinstance(to, str):
        if isinstance(ds_input, str):
          self.encoding = encoding
  
          Driver.ensure_registered()
  
        if isinstance(ds_input, str):
              # The data source driver is a void pointer.
              ds_driver = Driver.ptr_type()
              try:
                  # OGROpen will auto-detect the data source type.
                  ds = capi.open_ds(force_bytes(ds_input), self._write, byref(ds_driver))
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/gdal/datasource.py