coderholic / django-cities

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

Multiple object exception for get_preferred #53

Closed slollo closed 10 years ago

slollo commented 10 years ago
>>> from bp.cities.models import geo_alt_names, Region
>>> geo_alt_names[Region]["ru"].objects.get_preferred(geo__name="Adygeya", default="Adygeya")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/lollo/src/html/bp/bp/bp/../bp/cities/models.py", line 109, in get_preferred
    try: return self.get(is_preferred=True, **kwargs)
  File "/usr/lib/python2.7/dist-packages/django/db/models/manager.py", line 143, in get
    return self.get_query_set().get(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 407, in get
    (self.model._meta.object_name, num))
MultipleObjectsReturned: get() returned more than one RegionAltNameRu -- it returned 2!

2013-12-19 00 37 55

spout commented 8 years ago

Hello,

I don't see get_preferred() method on django-cities==0.4.2 ? I see the commit here, but I can't find the code on https://github.com/coderholic/django-cities/blob/master/cities/models.py ? An other commit removed this ?