mirror of
https://github.com/openSUSE/osc.git
synced 2025-08-31 18:34:11 +02:00
Fix exporting an empty model field in BaseModel.dict()
This commit is contained in:
@@ -339,8 +339,10 @@ class BaseModel(metaclass=ModelMeta):
|
||||
for name, field in self.__fields__.items():
|
||||
if field.exclude:
|
||||
continue
|
||||
if field.is_model:
|
||||
result[name] = getattr(self, name).dict()
|
||||
value = getattr(self, name)
|
||||
if value is not None and field.is_model:
|
||||
result[name] = value.dict()
|
||||
else:
|
||||
result[name] = getattr(self, name)
|
||||
result[name] = value
|
||||
|
||||
return result
|
||||
|
Reference in New Issue
Block a user