Răsfoiți Sursa

Include custom fields in ObjectChange data

Jeremy Stretch 7 ani în urmă
părinte
comite
f5f16ce64b
1 a modificat fișierele cu 9 adăugiri și 0 ștergeri
  1. 9 0
      netbox/utilities/utils.py

+ 9 - 0
netbox/utilities/utils.py

@@ -93,6 +93,15 @@ def serialize_object(obj, extra=None):
     """
     json_str = serialize('json', [obj])
     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:
         data.update(extra)
+
     return data