netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Public demo: https://demo.netbox.dev
http://netboxlabs.com/oss/netbox/
Apache License 2.0
15.71k stars 2.53k forks source link

Allow plugin models to be used as CustomField object if they don't provide webhooks #13784

Closed rixx closed 11 months ago

rixx commented 11 months ago

NetBox version

master

Feature type

Data model extension

Proposed functionality

Currently, only plugin models that provide the webhooks feature set are selectable for related custom fields. (There's already a TODO note there calling this out.) I'd like to mark my plugin's models as suitable for custom fields even without providing webhook integration.

Use case

I usually subclass NetBoxModel in my plugins. However, in this plugin, I'm shipping multiple plugins in a single package. This means that the import path to a model may be my_bundle.appname.models.MyModel, whereas its app_name is just appname.MyModel. As the webhooks integration attempts a dynamic import and fails if it cannot import appname.serializers.MyModelSerializer, I chose to exclude the webhook integration – however, I'd still like the plugin model to be available for custom fields.

Database changes

-

External dependencies

-

jeremystretch commented 11 months ago

This is one of the symptoms that would be corrected under #13427, and is currently planned for the v4.0 release. I'm going to close this out as it will be addressed by that work, but thank you for calling it out explicitly.