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.
Source:stackexchange.com