From ce27a1d211d8986089c2da11c34a0828316925ed Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 22 Jun 2018 15:27:22 -0400 Subject: [PATCH] serialize_object(): Allow extra data to overwrite existing fields --- netbox/utilities/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox/utilities/utils.py b/netbox/utilities/utils.py index c5ddda907..1eee8527c 100644 --- a/netbox/utilities/utils.py +++ b/netbox/utilities/utils.py @@ -89,10 +89,10 @@ def dynamic_import(name): def serialize_object(obj, extra=None): """ Return a generic JSON representation of an object using Django's built-in serializer. (This is used for things like - change logging, not the REST API.) + change logging, not the REST API.) Optionally include a dictionary to supplement the object data. """ json_str = serialize('json', [obj]) data = json.loads(json_str)[0]['fields'] if extra is not None: - data['extra'] = extra + data.update(extra) return data