Add ability to filter device by rack role #3994

Closed
opened 2025-12-29 18:32:31 +01:00 by adam · 3 comments
Owner

Originally created by @tobiasge on GitHub (Aug 18, 2020).

Environment

  • Python version: 3.7.3
  • NetBox version: v2.8.9

Proposed Functionality

Add Filter for rack role one device listing page

Use Case

Find all devices that are in racks with a specific role

Database Changes

None

External Dependencies

None

Edit:
I have implemented this and will create a PR if this issue is accepted.

Originally created by @tobiasge on GitHub (Aug 18, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for proposing specific new features or enhancements. If you have a general idea or question, please post to our mailing list instead of opening an issue: https://groups.google.com/forum/#!forum/netbox-discuss NOTE: Due to an excessive backlog of feature requests, we are not currently accepting any proposals which significantly extend NetBox's feature scope. Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.7.3 * NetBox version: v2.8.9 <!-- Describe in detail the new functionality you are proposing. Include any specific changes to work flows, data models, or the user interface. --> ### Proposed Functionality Add Filter for rack role one device listing page <!-- Convey an example use case for your proposed feature. Write from the perspective of a NetBox user who would benefit from the proposed functionality and describe how. ---> ### Use Case Find all devices that are in racks with a specific role <!-- Note any changes to the database schema necessary to support the new feature. For example, does the proposal require adding a new model or field? (Not all new features require database changes.) ---> ### Database Changes None <!-- List any new dependencies on external libraries or services that this new feature would introduce. For example, does the proposal require the installation of a new Python package? (Not all new features introduce new dependencies.) --> ### External Dependencies None Edit: I have implemented this and will create a PR if this issue is accepted.
adam added the type: featurestatus: under review labels 2025-12-29 18:32:31 +01:00
adam closed this issue 2025-12-29 18:32:31 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 18, 2020):

With limited exceptions, we generally don't support second-degree filtering of objects (e.g. filtering on an attribute of a related object). Doing so would necessitate devising a highly dynamic filtering solution to ensure consistent coverage with a minimum of code. Otherwise, we'd end up with hundreds of discrete, manually-defined filters that would be very difficult to maintain.

If you're interested in taking on this work, I'd suggest opening a new FR to propose a solution. Otherwise, we'll have to reject this because it takes us down the road of piecemealing out dozens of similar filters.

@jeremystretch commented on GitHub (Aug 18, 2020): With limited exceptions, we generally don't support second-degree filtering of objects (e.g. filtering on an attribute of a related object). Doing so would necessitate devising a highly dynamic filtering solution to ensure consistent coverage with a minimum of code. Otherwise, we'd end up with hundreds of discrete, manually-defined filters that would be very difficult to maintain. If you're interested in taking on this work, I'd suggest opening a new FR to propose a solution. Otherwise, we'll have to reject this because it takes us down the road of piecemealing out dozens of similar filters.
Author
Owner

@tobiasge commented on GitHub (Aug 18, 2020):

Since there is already a Rack group filter, I thought that this would be a good way to add this too.
I understand your point with this leading to too many filters.
At the moment I have not enough experience with Django filters to build a completely dynamic filtering system.

As this filter is important for us, what would you recommend to implement this?
A plugin or a custom script?

@tobiasge commented on GitHub (Aug 18, 2020): Since there is already a Rack group filter, I thought that this would be a good way to add this too. I understand your point with this leading to too many filters. At the moment I have not enough experience with Django filters to build a completely dynamic filtering system. As this filter is important for us, what would you recommend to implement this? A plugin or a custom script?
Author
Owner

@jeremystretch commented on GitHub (Aug 18, 2020):

At the moment I have not enough experience with Django filters to build a completely dynamic filtering system.

Unfortunately, open source projects like NetBox rely on members of the community to take the initiative. I can only take on so much by myself.

As this filter is important for us, what would you recommend to implement this?

Make two API calls: one to retrieve the relevant racks (filtered by role), and the second to filter devices by that set of rack IDs.

Going to close this issue out since it would need to be implemented under a much broader initiative as discussed above.

@jeremystretch commented on GitHub (Aug 18, 2020): > At the moment I have not enough experience with Django filters to build a completely dynamic filtering system. Unfortunately, open source projects like NetBox rely on members of the community to take the initiative. I can only take on so much by myself. > As this filter is important for us, what would you recommend to implement this? Make two API calls: one to retrieve the relevant racks (filtered by role), and the second to filter devices by that set of rack IDs. Going to close this issue out since it would need to be implemented under a much broader initiative as discussed above.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3994