Skip to content

Commit eabb48b

Browse files
committed
Fix BaseModel to initialize from a dictionary via __init__ instead of setattr
This solves an exception on instantiating an empty model with fields that are not optional
1 parent b4758fb commit eabb48b

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

osc/util/models.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,7 @@ def get(self, obj):
312312
# if this is a model field, convert dict to a model instance
313313
if self.is_model and isinstance(default, dict):
314314
cls = self.origin_type
315-
new_value = cls() # pylint: disable=not-callable
316-
for k, v in default.items():
317-
setattr(new_value, k, v)
318-
default = new_value
315+
default = cls(**default)
319316

320317
obj._defaults[self.name] = default
321318
return default

0 commit comments

Comments
 (0)