you should use `basestring` instead of `str` for checking type to also catch unicode. (or six: http://stackoverflow.com/a/20612311)