Просмотр исходного кода

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 год назад
Родитель
Сommit
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 []
     exclude = exclude or []
 
 
     # Include custom_field_data as "custom_fields"
     # 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')
         data['custom_fields'] = data.pop('custom_field_data')
 
 
     # Resolve any assigned tags to their names. Check for tags cached on the instance;
     # Resolve any assigned tags to their names. Check for tags cached on the instance;