Unable to filter by rack unit on elevations endpoint #3372

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

Originally created by @DanSheps on GitHub (Feb 21, 2020).

Originally assigned to: @DanSheps on GitHub.

Environment

  • Python version: 3.6.8
  • NetBox version: 2.7.8-dev

Steps to Reproduce

  1. Create a site
  2. Create a rack
  3. Perform API query against /api/dcim/racks/###/elevation?q=23

Expected Behavior

Only position 23 should be returned

Observed Behavior

All positions are returned

Originally created by @DanSheps on GitHub (Feb 21, 2020). Originally assigned to: @DanSheps on GitHub. ### Environment * Python version: 3.6.8 * NetBox version: 2.7.8-dev ### Steps to Reproduce 1. Create a site 2. Create a rack 3. Perform API query against /api/dcim/racks/###/elevation?q=23 ### Expected Behavior Only position 23 should be returned ### Observed Behavior All positions are returned
adam added the type: bugstatus: accepted labels 2025-12-29 18:28:28 +01:00
adam closed this issue 2025-12-29 18:28:28 +01:00
Author
Owner

@DanSheps commented on GitHub (Feb 21, 2020):

20b36f910f/netbox/dcim/api/views.py (L239)

Insert:

            # Enable filtering rack units by ID
            q = request.GET.get('q', None)
            if q:
                elevation = [u for u in elevation if q in str(u['id'])]

Should re-enable filtering for positions at the very least. This is affecting the any APISelect widget that references /racks/###/elevation and filters by position (or potentially any other filter element either).

@DanSheps commented on GitHub (Feb 21, 2020): https://github.com/netbox-community/netbox/blob/20b36f910f45563f05ef7295dd7cb705afad3af3/netbox/dcim/api/views.py#L239 Insert: ``` # Enable filtering rack units by ID q = request.GET.get('q', None) if q: elevation = [u for u in elevation if q in str(u['id'])] ``` Should re-enable filtering for positions at the very least. This is affecting the any APISelect widget that references /racks/###/elevation and filters by position (or potentially any other filter element either).
Author
Owner

@lampwins commented on GitHub (Feb 21, 2020):

Ha, that the time this was taken out, no one could answer what it was used for. Now that we know, it would be really nice to have a test for it.

@lampwins commented on GitHub (Feb 21, 2020): Ha, that the time this was taken out, no one could answer what it was used for. Now that we know, it would be really nice to have a test for it.
Author
Owner

@DanSheps commented on GitHub (Feb 21, 2020):

Yeah, I was thinking we could add just a simple API test for it. Couple of queries against a rack, make sure we get back stuff that makes sense.

@DanSheps commented on GitHub (Feb 21, 2020): Yeah, I was thinking we could add just a simple API test for it. Couple of queries against a rack, make sure we get back stuff that makes sense.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3372