Extend filter forms to support filter modifiers #5546

Closed
opened 2025-12-29 19:29:16 +01:00 by adam · 9 comments
Owner

Originally created by @jeremystretch on GitHub (Oct 21, 2021).

Originally assigned to: @jnovinger on GitHub.

NetBox version

v3.0.8

Feature type

Change to existing functionality

Proposed functionality

When viewing a list of objects in the NetBox UI, a "filters" tab is present and lists all of the available filters for the relevant model. However, these filters utilize only the default behavior of each filter, and don't allow for modifications to the filter expressions defined here.

This FR proposes to extend the filter forms to include a dropdown widget for each appropriate field, allowing the user to select the desired logic. For example, when filtering by an integer value, the default behavior will be "equals," but options for "less than" (lt) and "greater than" (gt) will also be available.

Use case

Although these filter expressions are technically available and working in the current release, this addition to the user interface would make them much more convenient to use.

Database changes

No response

External dependencies

No response

Originally created by @jeremystretch on GitHub (Oct 21, 2021). Originally assigned to: @jnovinger on GitHub. ### NetBox version v3.0.8 ### Feature type Change to existing functionality ### Proposed functionality When viewing a list of objects in the NetBox UI, a "filters" tab is present and lists all of the available filters for the relevant model. However, these filters utilize only the default behavior of each filter, and don't allow for modifications to the filter expressions defined [here](https://netbox.readthedocs.io/en/stable/rest-api/filtering/#lookup-expressions). This FR proposes to extend the filter forms to include a dropdown widget for each appropriate field, allowing the user to select the desired logic. For example, when filtering by an integer value, the default behavior will be "equals," but options for "less than" (`lt`) and "greater than" (`gt`) will also be available. ### Use case Although these filter expressions are technically available and working in the current release, this addition to the user interface would make them much more convenient to use. ### Database changes _No response_ ### External dependencies _No response_
adam added the status: acceptedtype: featurenetboxcomplexity: high labels 2025-12-29 19:29:16 +01:00
adam closed this issue 2025-12-29 19:29:16 +01:00
Author
Owner

@jeremystretch commented on GitHub (Dec 13, 2021):

Per #7587 this should also include the ability to negate/invert a filter.

@jeremystretch commented on GitHub (Dec 13, 2021): Per #7587 this should also include the ability to negate/invert a filter.
Author
Owner

@github-actions[bot] commented on GitHub (Feb 12, 2022):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Feb 12, 2022): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@jeremystretch commented on GitHub (Sep 13, 2022):

We should explore what's feasible for #10352 first, as we can likely build on that solution to implement this.

@jeremystretch commented on GitHub (Sep 13, 2022): We should explore what's feasible for #10352 first, as we can likely build on that solution to implement this.
Author
Owner

@jsenecal commented on GitHub (Oct 24, 2022):

So, I was thinking of something like this:
image

I still have yet to find the proper way of doing it within Django but this is the gist of it. I was thinking of adding this under some sort of "advanced search" accordion.

Does this makes sense to you ?

@jsenecal commented on GitHub (Oct 24, 2022): So, I was thinking of something like this: ![image](https://user-images.githubusercontent.com/1564902/197538664-be055ac7-941e-4c83-93e5-174cc7355b17.png) I still have yet to find the proper way of doing it within Django but this is the gist of it. I was thinking of adding this under some sort of "advanced search" accordion. Does this makes sense to you ?
Author
Owner

@jeremystretch commented on GitHub (Oct 25, 2022):

I would prefer to keep each of the filters displayed individually under the "filters" tab, rather than requiring the use to select the desired filter(s) from a dropdown. Additionally, this sort of matrix only seems to makes sense where the user needs to supply a value. When filtering by related objects, an option to invert the logic (excluding the selected objects) seems sufficient.

@jeremystretch commented on GitHub (Oct 25, 2022): I would prefer to keep each of the filters displayed individually under the "filters" tab, rather than requiring the use to select the desired filter(s) from a dropdown. Additionally, this sort of matrix only seems to makes sense where the user needs to supply a value. When filtering by related objects, an option to invert the logic (excluding the selected objects) seems sufficient.
Author
Owner

@jeremystretch commented on GitHub (Nov 2, 2022):

Per @jsenecal unfortunately this won't be done in time for the v3.4 beta, so I'm going to drop it from the milestone.

@jeremystretch commented on GitHub (Nov 2, 2022): Per @jsenecal unfortunately this won't be done in time for the v3.4 beta, so I'm going to drop it from the milestone.
Author
Owner

@jeremystretch commented on GitHub (Jan 5, 2023):

@jsenecal do you still want to tackle this?

@jeremystretch commented on GitHub (Jan 5, 2023): @jsenecal do you still want to tackle this?
Author
Owner

@jsenecal commented on GitHub (Jan 25, 2023):

Not sure I'm up to the task, work has the better part of me lately, I'll unassign myself.

@jsenecal commented on GitHub (Jan 25, 2023): Not sure I'm up to the task, work has the better part of me lately, I'll unassign myself.
Author
Owner

@jnovinger commented on GitHub (Jul 19, 2025):

I took a stab at this, with the goals being:

  • Maintain consistency with the rest of the NetBox UI/UX
  • Have as little JS enhancement as possible
  • Use the existing dependencies we have, nothing new
  • Leverage as much of the existing infrastructure as possible
    • No changes to filtersets, just introspection.
    • Leverages existing filter modifier functionality.
    • Rendered from Django templates, but enhanced by JS

There are three mockups, both very similar:

  1. Uses the base Bootstrap style.
  2. Is basically the same as the previous style but uses a thin, gray trace line to connect the lookup selector and the input field (the "Trace" style).
  3. Uses the "Pill" style to indicate that the fields go together.

See the attached screenshot. But also check out the attached code to play with an interactive version of this in a standalone HTML page in your browser. When interacting with the mockups, be sure to view them in mobile dimensions to get a sense of how the respond.

Image

Mockup source (download as HTML and open in browser to interact): https://gist.github.com/jnovinger/b88850eaadbe30c46c10f84971f53889

@jnovinger commented on GitHub (Jul 19, 2025): I took a stab at this, with the goals being: - Maintain consistency with the rest of the NetBox UI/UX - Have as little JS enhancement as possible - Use the existing dependencies we have, nothing new - Leverage as much of the existing infrastructure as possible - No changes to filtersets, just introspection. - Leverages existing filter modifier functionality. - Rendered from Django templates, but enhanced by JS There are three mockups, both very similar: 1. Uses the base Bootstrap style. 2. Is basically the same as the previous style but uses a thin, gray trace line to connect the lookup selector and the input field (the "Trace" style). 3. Uses the "Pill" style to indicate that the fields go together. See the attached screenshot. But also check out the attached code to play with an interactive version of this in a standalone HTML page in your browser. When interacting with the mockups, be sure to view them in mobile dimensions to get a sense of how the respond. <img width="982" height="1430" alt="Image" src="https://github.com/user-attachments/assets/60a7112a-2910-4ac4-879f-960d0e1374eb" /> Mockup source (download as HTML and open in browser to interact): https://gist.github.com/jnovinger/b88850eaadbe30c46c10f84971f53889
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5546