فهرست منبع

Cover multitable inheritance in serialization

During serialization, custom fields may be available to a model due to
multi-table inheritance, but might not be available in serialized data
because only direct fields of the model are covered. Now this attribute
is only used if available in serialized data. Models using multi-table
inheritance must modify their serialize_object() method to cover parent
serialization.
Alexander Haase 1 سال پیش
والد
کامیت
b5bc0bad38
1فایلهای تغییر یافته به همراه1 افزوده شده و 1 حذف شده
  1. 1 1
      netbox/utilities/serialization.py

+ 1 - 1
netbox/utilities/serialization.py

@@ -29,7 +29,7 @@ def serialize_object(obj, resolve_tags=True, extra=None, exclude=None):
     exclude = exclude or []
 
     # Include custom_field_data as "custom_fields"
-    if hasattr(obj, 'custom_field_data'):
+    if 'custom_field_data' in data:
         data['custom_fields'] = data.pop('custom_field_data')
 
     # Resolve any assigned tags to their names. Check for tags cached on the instance;