django: results in in_bulk style without IDs

Posted by valya on Stack Overflow See other posts from Stack Overflow or by valya
Published on 2010-04-10T17:40:09Z Indexed on 2010/04/10 17:43 UTC
Read the original article Hit count: 241

Filed under:
|

in django 1.1.1, Place.objects.in_bulk() does not work and Place.objects.in_bulk(range(1, 100)) works and returns a dictionary of Ints to Places with indexes - primary keys. How to avoid using range in this situation (and avoid using a special query for ids, I just want to get all objects in this dictionary format)

>>> Place.objects.in_bulk()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/Django-1.1.1-py2.5.egg/django/db/models/manager.py", line 144, in in_bulk
    return self.get_query_set().in_bulk(*args, **kwargs)
TypeError: in_bulk() takes exactly 2 arguments (1 given)
>>> Place.objects.in_bulk(range(1, 100))
{1L: <Place: "??? ????">, 3L: <Place: "???????????? ?????">, 4L: <Place: "????????? "??????"">, 5L: <Place: "????????? "??????"">, 8L: <Place: "????????? "??????????????"">, 9L: <Place: "??????? ????????">, 10L: <Place: "????????? ???????">, 11L: <Place: "??????????????? ???">, 14L: <Place: "????? ????? ??????">}

© Stack Overflow or respective owner

Related posts about django

Related posts about django-models