Support filterset registration for plugins #11932

Open
opened 2025-12-29 21:51:40 +01:00 by adam · 2 comments
Owner

Originally created by @jeremystretch on GitHub (Dec 17, 2025).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v4.4.8

Feature type

New functionality

Proposed functionality

Extend the plugins API to support the registration of filtersets within plugins, using the register_filterset() decorator.

Use case

This will enable the automatic attachment of filter lookups (introduced in NetBox v4.5) for plugins, as well as potential future functionality.

Database changes

N/A

External dependencies

N/A

Originally created by @jeremystretch on GitHub (Dec 17, 2025). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v4.4.8 ### Feature type New functionality ### Proposed functionality Extend the plugins API to support the registration of filtersets within plugins, using the `register_filterset()` decorator. ### Use case This will enable the automatic attachment of filter lookups (introduced in NetBox v4.5) for plugins, as well as potential future functionality. ### Database changes N/A ### External dependencies N/A
adam added the status: acceptedtype: featuretopic: pluginsnetboxcomplexity: low labels 2025-12-29 21:51:40 +01:00
Author
Owner

@peteeckel commented on GitHub (Dec 18, 2025):

Hi @jeremystretch - following up on our exchange yesterday:

diff --git a/docs/plugins/development/filtersets.md b/docs/plugins/development/filtersets.md
index e829ddea5..36e6346c5 100644
--- a/docs/plugins/development/filtersets.md
+++ b/docs/plugins/development/filtersets.md
@@ -6,12 +6,17 @@ Filter sets define the mechanisms available for filtering or searching through a
 
 To support additional functionality standard to NetBox models, such as tag assignment and custom field support, the `NetBoxModelFilterSet` class is available for use by plugins. This should be used as the base filter set class for plugin models which inherit from `NetBoxModel`. Within this class, individual filters can be declared as directed by the `django-filters` documentation. An example is provided below.
 
+!!! info "New in NetBox v4.5: FilterSet Registration"
+    NetBox v4.5 introduced the `register_filterset()` utility function. This enables plugins to register their filtersets to receive advanced functionality, such as the automatic attachment of field-specific lookup modifiers on the filter form. Registration is optional: Unregistered filtersets will continue to work as before, but will not receive the enhanced functionality.
+
...

Actually this has already been documented for 4.5, so probably that was premature.

@peteeckel commented on GitHub (Dec 18, 2025): Hi @jeremystretch - following up on our exchange yesterday: ``` diff --git a/docs/plugins/development/filtersets.md b/docs/plugins/development/filtersets.md index e829ddea5..36e6346c5 100644 --- a/docs/plugins/development/filtersets.md +++ b/docs/plugins/development/filtersets.md @@ -6,12 +6,17 @@ Filter sets define the mechanisms available for filtering or searching through a To support additional functionality standard to NetBox models, such as tag assignment and custom field support, the `NetBoxModelFilterSet` class is available for use by plugins. This should be used as the base filter set class for plugin models which inherit from `NetBoxModel`. Within this class, individual filters can be declared as directed by the `django-filters` documentation. An example is provided below. +!!! info "New in NetBox v4.5: FilterSet Registration" + NetBox v4.5 introduced the `register_filterset()` utility function. This enables plugins to register their filtersets to receive advanced functionality, such as the automatic attachment of field-specific lookup modifiers on the filter form. Registration is optional: Unregistered filtersets will continue to work as before, but will not receive the enhanced functionality. + ... ``` Actually this has already been documented for 4.5, so probably that was premature.
Author
Owner

@jeremystretch commented on GitHub (Dec 18, 2025):

Ah, that's my mistake then. I was misremembering a conversation we had around #7604. As initially implemented, the lookups were being added automatically for all filtersets. But there was concern that this would potentially be breaking (sort of an unknown unknown) and we didn't want to introduce that liability, so we introduced the register_filterset() function as an opt-in for the functionality.

I suppose this needs to be called out for plugins specifically in the release notes as well.

@jeremystretch commented on GitHub (Dec 18, 2025): Ah, that's my mistake then. I was misremembering a conversation we had around #7604. As initially implemented, the lookups were being added automatically for all filtersets. But there was concern that this would potentially be breaking (sort of an unknown unknown) and we didn't want to introduce that liability, so we introduced the `register_filterset()` function as an opt-in for the functionality. I suppose this needs to be called out for plugins specifically in the release notes as well.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11932