mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-02 04:24:46 +00:00
Cleaner implementation of ChooserBlock.bulk_to_python
This commit is contained in:
parent
b54b2d837c
commit
ec55c5d73c
1 changed files with 1 additions and 3 deletions
|
|
@ -432,10 +432,8 @@ class ChooserBlock(FieldBlock):
|
|||
|
||||
The instances must be returned in the same order as the values and keep None values.
|
||||
"""
|
||||
initial = {key: None for key in values}
|
||||
objects = self.target_model.objects.in_bulk(values)
|
||||
initial.update(objects)
|
||||
return [initial[id] for id in values] # Keeps the ordering the same as in values.
|
||||
return [objects.get(id) for id in values] # Keeps the ordering the same as in values.
|
||||
|
||||
def get_prep_value(self, value):
|
||||
# the native value (a model instance or None) should serialise to a PK or None
|
||||
|
|
|
|||
Loading…
Reference in a new issue