support updating models on the many side of the one-to-many relations.

This commit is contained in:
EspenAlbert
2020-11-24 08:40:19 +00:00
parent 29c364675f
commit 3eccd05ece
2 changed files with 19 additions and 0 deletions

View File

@ -70,6 +70,12 @@ class ModelTableProxy:
f"model without pk set!"
)
model_dict[field] = pk_value
elif isinstance(field_value, list):
targets = [target.get(target_pkname) for target in field_value]
if targets:
model_dict[field] = targets
else:
model_dict.pop(field)
elif field_value: # nested dict
model_dict[field] = field_value.get(target_pkname)
else: