Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cover multi-table inheritance in change logged models #18277

Open
alehaa opened this issue Dec 29, 2024 · 0 comments
Open

Cover multi-table inheritance in change logged models #18277

alehaa opened this issue Dec 29, 2024 · 0 comments
Labels
status: needs triage This issue is awaiting triage by a maintainer type: feature Introduction of new functionality to the application

Comments

@alehaa
Copy link
Contributor

alehaa commented Dec 29, 2024

NetBox version

v4.1.10

Feature type

Change to existing functionality

Triage priority

I volunteer to perform this work (if approved)

Proposed functionality

Currently the serialize_object() utility function checks if the model has the custom_field_data attribute.

if hasattr(obj, 'custom_field_data'):
data['custom_fields'] = data.pop('custom_field_data')

I suggest changing this to check if the key actually exists in the data dictionary.

Use case

A plugin could extend existing NetBox models using multi-table inheritance. However, although the attribute is available on the child model class, the data is actually stored in the parent model. Serializing the object during the automatic creation of the ObjectChange will therefore raise an exception, as the attribute is available, but won't be serialized in the data dictionary.

Although NetBox should not cover serialization for this scenario, changing this would allow plugins more possibilities. NetBox simply wouldn't handle this attribute in this scenario, leaving it to the developer to implement. No exceptions will be thrown either.

Database changes

None

External dependencies

None

@alehaa alehaa added status: needs triage This issue is awaiting triage by a maintainer type: feature Introduction of new functionality to the application labels Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue is awaiting triage by a maintainer type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

1 participant