Filtering on multiple inputs in custom scripts only returns last input #5201

Closed
opened 2025-12-29 19:25:23 +01:00 by adam · 2 comments
Owner

Originally created by @rodvand on GitHub (Aug 19, 2021).

Originally assigned to: @thatmattlove on GitHub.

NetBox version

v3.0-beta2

Python version

3.8

Steps to Reproduce

  1. Create a custom script with the following code:
class Test:
  device = ObjectVar(
    model = Device,
    query_params = {
      "name__ic": ["akron-pdu01", "akron-rtr01"]
    },
  )

  class run(self, data, commit):
    pass

Expected Behavior

In the device dropdown menu to see devices "dmi01-akron-pdu01" and "dmi01-akron-rtr01".

Observed Behavior

Only the device "dmi01-akron-rtr01" is shown. If you use developer tools to see the requests you can see the request only using the last device in the query.

The query https://beta-demo.netbox.dev/dcim/devices/?name__ic=akron-pdu01&name__ic=akron-rtr01 works as expected.

Originally created by @rodvand on GitHub (Aug 19, 2021). Originally assigned to: @thatmattlove on GitHub. ### NetBox version v3.0-beta2 ### Python version 3.8 ### Steps to Reproduce 1. Create a custom script with the following code: ``` class Test: device = ObjectVar( model = Device, query_params = { "name__ic": ["akron-pdu01", "akron-rtr01"] }, ) class run(self, data, commit): pass ``` ### Expected Behavior In the device dropdown menu to see devices "dmi01-akron-pdu01" and "dmi01-akron-rtr01". ### Observed Behavior Only the device "dmi01-akron-rtr01" is shown. If you use developer tools to see the requests you can see the request only using the last device in the query. The query https://beta-demo.netbox.dev/dcim/devices/?name__ic=akron-pdu01&name__ic=akron-rtr01 works as expected.
adam added the type: bugstatus: acceptedbeta labels 2025-12-29 19:25:23 +01:00
adam closed this issue 2025-12-29 19:25:23 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 20, 2021):

Looks like the issue is that we're using a mapping of filter parameter names to individual values:

84db2e90ab/netbox/project-static/src/select/api.ts (L786)

We should be able to fix this by using a list of values for each filter, and appending the filter to the API URL once per value.

@jeremystretch commented on GitHub (Aug 20, 2021): Looks like the issue is that we're using a mapping of filter parameter names to individual values: https://github.com/netbox-community/netbox/blob/84db2e90abe594cce7d53669320c1272843ff27c/netbox/project-static/src/select/api.ts#L786 We should be able to fix this by using a list of values for each filter, and appending the filter to the API URL once per value.
Author
Owner

@thatmattlove commented on GitHub (Aug 21, 2021):

This, along with multiple other similar bugs related to dynamic query params/filters, should now be fixed.

@thatmattlove commented on GitHub (Aug 21, 2021): This, along with multiple other similar bugs related to dynamic query params/filters, should now be fixed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5201