[Answered ]-Django: results in in_bulk style without IDs

3👍

This would work:

dict((obj._get_pk_val(), obj) for obj in Place.objects.all())

It is essentially what in_bulk would do without a list of ids.

In most cases you can replace obj._get_pk_val() by obj.pk if you did not mess with the pk names.

-1👍

I think you need this:

Place.objects.in_bulk(Place.objects.all().values('id'))

Leave a comment