mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-03 21:36:15 +01:00
Fix initializing a sub-model instance from a dictionary
This commit is contained in:
parent
35433fc341
commit
3baeb4b64e
@ -252,10 +252,9 @@ class Field(property):
|
||||
def set(self, obj, value):
|
||||
# if this is a model field, convert dict to a model instance
|
||||
if self.is_model and isinstance(value, dict):
|
||||
new_value = self.origin_type() # pylint: disable=not-callable
|
||||
for k, v in value.items():
|
||||
setattr(new_value, k, v)
|
||||
value = new_value
|
||||
# initialize a model instance from a dictionary
|
||||
klass = self.origin_type
|
||||
value = klass(**value) # pylint: disable=not-callable
|
||||
|
||||
self.validate_type(value)
|
||||
obj._values[self.name] = value
|
||||
|
Loading…
Reference in New Issue
Block a user