mirror of
https://github.com/openSUSE/osc.git
synced 2025-09-08 05:58:43 +02:00
Fix BaseModel to convert dictionaries to objects on retrieving a model list
This commit is contained in:
@@ -249,8 +249,18 @@ class Field(property):
|
||||
def get(self, obj):
|
||||
try:
|
||||
result = obj._values[self.name]
|
||||
|
||||
# convert dictionaries into objects
|
||||
# we can't do it earlier because list is a standalone object that is not under our control
|
||||
if result is not None and self.is_model_list:
|
||||
for num, i in enumerate(result):
|
||||
if isinstance(i, dict):
|
||||
klass = self.inner_type
|
||||
result[num] = klass(**i)
|
||||
|
||||
if self.get_callback is not None:
|
||||
result = self.get_callback(obj, result)
|
||||
|
||||
return result
|
||||
except KeyError:
|
||||
pass
|
||||
|
Reference in New Issue
Block a user