ImportError: cannot import name 'StringType'

Viewed 12413

I took some sample code that was made in the django version 1.8.4, and like Python 2.7 when transferred to 3 python all flown away and produced such an error, how to fix it?

\lib\site-packages\config.py", line 91, in <module>
        from types import StringType, UnicodeType
    ImportError: cannot import name 'StringType'

one piece of code where using stringtype (config.py)(in site-packages)

def writeValue(self, value, stream, indent):
        if isinstance(self, Mapping):
            indstr = ' '
        else:
            indstr = indent * '  '
        if isinstance(value, Reference) or isinstance(value, Expression):
            stream.write('%s%r%s' % (indstr, value, NEWLINE))
        else:
            if (type(value) is StringType): # and not isWord(value):
                value = repr(value)
            stream.write('%s%s%s' % (indstr, value, NEWLINE))
2 Answers
Related