coderholic / django-cities

Countries and cities of the world for Django projects
MIT License
927 stars 372 forks source link

Python 3 Incompatibility - from django.utils.encoding import force_unicode #91

Closed stantond closed 9 years ago

stantond commented 9 years ago

After installing, I ran into this error when running python manage.py makemigrations:

c:\web\tabletop\src>python manage.py makemigrations Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "C:\Python34\lib\site-packages\django\core\managementinit.py", line 338, in execute_from_command_line utility.execute() File "C:\Python34\lib\site-packages\django\core\managementinit.py", line 312, in execute django.setup() File "C:\Python34\lib\site-packages\djangoinit.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Python34\lib\site-packages\django\apps\registry.py", line 108, in populate app_config.import_models(all_models) File "C:\Python34\lib\site-packages\django\apps\config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "C:\Python34\lib\importlibinit.py", line 109, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 2254, in _gcd_import File "", line 2237, in _find_and_load File "", line 2226, in _find_and_load_unlocked File "", line 1200, in _load_unlocked File "", line 1129, in _exec File "", line 1471, in exec_module File "", line 321, in _call_with_frames_removed File "C:\Python34\lib\site-packages\cities\models.py", line 1, in from django.utils.encoding import force_unicode ImportError: cannot import name 'force_unicode'

Python 3 doesn't use unicode. See the documentation here for str and unicode methods - essentially, use __str__() with a Python 2 compatibility decorator. force_unicode has been replaced with force_text

stantond commented 9 years ago

See https://github.com/coderholic/django-cities/issues/94

coderholic commented 9 years ago

Can you confirm is this is still a problem or not with 0.4.2 from pypi?

stantond commented 9 years ago

This was resolved when I installed the latest version from the github repo, so shouldn't be an issue with 0.4.2.