Make sure we show relative object information in the api

This commit is contained in:
Matthew Jones
2013-11-12 14:30:01 -05:00
parent 50fee99580
commit 1a27c75de4
3 changed files with 41 additions and 19 deletions

View File

@@ -255,3 +255,12 @@ def model_instance_diff(old, new):
diff = None
return diff
def model_to_dict(obj):
"""
Serialize a model instance to a dictionary as best as possible
"""
attr_d = {}
for field in obj._meta.fields:
attr_d[field.name] = str(getattr(obj, field.name, None))
return attr_d