You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, a NetBox model must meet two conditions for custom fields to function properly:
Inherit from CustomFieldsMixin
Register as having custom fields via the extras_features() decorator
The second step is redundant, given that it should be assumed that any model inheriting from CustomFieldsMixin supports custom fields. However, failing to register via extras_features() excludes the model from the list of available models when creating a custom field, and from other such selections.
We can obviate the need to register the model explicitly by instead connecting a receiver function to Django's class_prepared signal and checking for custom field support on the class.
Justification
Eliminates redundant code and reduces the possibility for human error.
The text was updated successfully, but these errors were encountered:
A similar issue exists with the declaration of support for tags: A model must both inherit from TagsMixin (to receive the appropriate manager) and register via extras_features().
Proposed Changes
Currently, a NetBox model must meet two conditions for custom fields to function properly:
extras_features()
decoratorThe second step is redundant, given that it should be assumed that any model inheriting from CustomFieldsMixin supports custom fields. However, failing to register via
extras_features()
excludes the model from the list of available models when creating a custom field, and from other such selections.We can obviate the need to register the model explicitly by instead connecting a receiver function to Django's
class_prepared
signal and checking for custom field support on the class.Justification
Eliminates redundant code and reduces the possibility for human error.
The text was updated successfully, but these errors were encountered: