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

Closed
opened 2025-12-29 20:39:05 +01:00 by adam · 1 comment
Owner

Originally created by @rixx on GitHub (Sep 15, 2023).

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

Originally created by @rixx on GitHub (Sep 15, 2023). ### NetBox version master ### Feature type Data model extension ### Proposed functionality Currently, only plugin models that provide the `webhooks` feature set [are selectable](https://github.com/netbox-community/netbox/blob/develop/netbox/extras/forms/model_forms.py#L53) 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 -
adam added the type: feature label 2025-12-29 20:39:05 +01:00
adam closed this issue 2025-12-29 20:39:05 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 15, 2023):

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.

@jeremystretch commented on GitHub (Sep 15, 2023): 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8628