Skip to content

Commit 9a41075

Browse files
authored
Option Compression: add some polish (#10583)
1 parent 0a93aa6 commit 9a41075

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

dojo/importers/options.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,11 @@ def compress_options(self):
119119
# Accommodate lists of fields
120120
elif isinstance(value, list) and len(value) > 0 and isinstance(value[0], Model):
121121
id_list = [item.id for item in value]
122+
item_type = type(value[0])
122123
class_name = None
123124
# Get the actual class if available
124125
if len(id_list) > 0:
125-
class_name = type(id_list[0])
126+
class_name = item_type
126127
# Ensure we are not setting a class name as None
127128
if class_name is type(None):
128129
compressed_fields[field] = value
@@ -149,7 +150,7 @@ def decompress_options(self):
149150
if class_name is type(None):
150151
model_list = model_value
151152
else:
152-
model_list = [class_name.objects.get(id=model_id) for model_id in model_value]
153+
model_list = list(class_name.objects.filter(id__in=model_value))
153154
decompressed_fields[field] = model_list
154155
elif isinstance(model_value, int):
155156
# Check for SimpleLazyObject that will be user objects

0 commit comments

Comments
 (0)