Include custom fields in ObjectChange data

This commit is contained in:
Jeremy Stretch 2018-06-29 10:40:57 -04:00
parent 06dab9c468
commit f5f16ce64b

View File

@ -93,6 +93,15 @@ def serialize_object(obj, extra=None):
""" """
json_str = serialize('json', [obj]) json_str = serialize('json', [obj])
data = json.loads(json_str)[0]['fields'] data = json.loads(json_str)[0]['fields']
# Include any custom fields
if hasattr(obj, 'get_custom_fields'):
data['custom_fields'] = {
field.name: value for field, value in obj.get_custom_fields().items()
}
# Append any extra data
if extra is not None: if extra is not None:
data.update(extra) data.update(extra)
return data return data