coderholic / django-cities

Countries and cities of the world for Django projects
MIT License
930 stars 374 forks source link

District import is failing when using MySQL #204

Open calinrada opened 6 years ago

calinrada commented 6 years ago

Environment:

Python 3.6.4 Django 2.0.7 django-cities 0.5.0.6 Ubuntu 16.04 MySQL 5.7

Command:

$ manage.py cities import

or

$ manage.py cities --import=district

Importing districts will fail with a ValueError exception that it's not handled.

https://github.com/coderholic/django-cities/blob/1a60b31c4d7eb43e4cd6ee0e5fa4d7908c0db07c/cities/management/commands/cities.py#L635

I have solved this by modifying L635 as follows:

 except (City.DoesNotExist, ValueError) as e: