(cls: type["T"], model: "T", values: builtins.dict)
| 1235 | |
| 1236 | @classmethod |
| 1237 | def _construct_relations(cls: type["T"], model: "T", values: builtins.dict) -> None: |
| 1238 | present_relations = [ |
| 1239 | relation for relation in cls.extract_related_names() if relation in values |
| 1240 | ] |
| 1241 | for relation in present_relations: |
| 1242 | value_to_set = values[relation] |
| 1243 | if not isinstance(value_to_set, list): |
| 1244 | value_to_set = [value_to_set] |
| 1245 | relation_field = cls.ormar_config.model_fields[relation] |
| 1246 | relation_value = [ |
| 1247 | relation_field.expand_relationship(x, model, to_register=False) |
| 1248 | for x in value_to_set |
| 1249 | if x is not None |
| 1250 | ] |
| 1251 | |
| 1252 | for child in relation_value: |
| 1253 | model._orm.add( |
| 1254 | parent=cast("Model", child), |
| 1255 | child=cast("Model", model), |
| 1256 | field=cast("ForeignKeyField", relation_field), |
| 1257 | ) |
| 1258 | |
| 1259 | def update_from_dict(self, value_dict: builtins.dict) -> "NewBaseModel": |
| 1260 | """ |
no test coverage detected