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.
This commit is contained in:
Alexander Haase 2025-02-18 21:48:12 +01:00 committed by Jeremy Stretch
parent 2a44affd03
commit b5bc0bad38

View File

@ -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;