summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--frest/utils.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/frest/utils.py b/frest/utils.py
index ef673a7..e145b32 100644
--- a/frest/utils.py
+++ b/frest/utils.py
@@ -33,12 +33,18 @@ def model_serialize(obj, params="", extend_model_for=[]):
for v in value:
for i in extend_model_for:
if isinstance(v, i):
- _l.append(v.as_json())
+ if hasattr(v, 'as_json'):
+ _l.append(v.as_json())
+ else:
+ _l.append(v)
fields[key] = _l
else:
for i in extend_model_for:
if isinstance(value, i):
- fields[key] = value.as_json()
+ if hasattr(value, 'as_json'):
+ fields[key] = value.as_json()
+ else:
+ fields[key] = value
return fields