Calling queyset.in_bulk (without any arguments) should evaluate the whole queryset.
|Reported by:||ElliottM||Owned by:||Bryan Marty|
|Component:||Database layer (models, ORM)||Version:||master|
|Severity:||Normal||Keywords:||in_bulk filter list|
|Cc:||Joseph Gordon, pramodpsb@…||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
in_bulk() works well if you know beforehand which ids you want to pull out. It becomes irritating, however, if you want to map an entire queryset at once.
Right now you have to do the following:
id_list=list(Book.objects.filter(author__name='Douglas Adams').values_list('id', flat=True)) bulk=Book.objects.in_bulk(id_list)
With the patch included, the following will now work:
I feel the second way is easier to read, and I really don't see any reason why people shouldn't be allowed to do this.
Change History (18)
comment:1 Changed 8 years ago by
|Triage Stage:||Unreviewed → Design decision needed|
comment:7 Changed 6 years ago by
|Patch needs improvement:||set|
|Triage Stage:||Design decision needed → Accepted|
comment:13 Changed 14 months ago by
|Owner:||changed from nobody to Bryan Marty|
|Status:||new → assigned|