django-cities: django-cities returns a MultipleObjectsReturned exception raised while importing
Checklist
- I have verified that I am using a GIS-enabled database, such as PostGIS or Spatialite.
- I have verified that that issue exists against the
masterbranch of django-cities. - I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
- I have reduced the issue to the simplest possible case.
- I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)
Steps to reproduce
python project/manage.py cities --import=all
Expected behavior
Sucessful import
Actual behavior
Traceback (most recent call last):
File "project/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/vagrant/environment/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/home/vagrant/environment/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/vagrant/environment/venv/lib/python3.4/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/vagrant/environment/venv/lib/python3.4/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/usr/lib/python3.4/contextlib.py", line 30, in inner
return func(*args, **kwds)
File "/home/vagrant/environment/venv/lib/python3.4/site-packages/cities/management/commands/cities.py", line 160, in handle
func()
File "/home/vagrant/environment/venv/lib/python3.4/site-packages/cities/management/commands/cities.py", line 1005, in import_postal_code
region__country=pc.country)
File "/home/vagrant/environment/venv/lib/python3.4/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/vagrant/environment/venv/lib/python3.4/site-packages/django/db/models/query.py", line 384, in get
(self.model._meta.object_name, num)
cities.models.MultipleObjectsReturned: get() returned more than one Subregion -- it returned 2!
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 22
Commits related to this issue
- Multiple subregion error https://github.com/coderholic/django-cities/issues/180 — committed to hetojoan/django-cities by hetojoan 6 years ago
- Update cities.py Added workaround from here: https://github.com/coderholic/django-cities/issues/180#issuecomment-429659162 — committed to sowinski/django-cities by sowinski 6 years ago
The topic issue still happens.
@mayela I think the fix for this is:
but I don’t really have time to add it to the test data and verify it.