Not possible to specify more than one multiselect value in ObjectWidget URL parameters #7924

Closed
opened 2025-12-29 20:30:02 +01:00 by adam · 1 comment
Owner

Originally created by @kkthxbye-code on GitHub (Apr 19, 2023).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.5.0-beta2

Python version

3.8

Steps to Reproduce

  1. Create a new ObjectWidget list with the Model "DCIM > Device".
  2. In the URL parameters filter by two different location_id's:
{
    "location_id": 1,
    "location_id": 2
}
  1. Save the widget

Expected Behavior

Widget should show devices belonging to either location with the id of 1 or 2.

Observed Behavior

Devices with location id 2 are shown. As the filters are passed as a JSON field and converted to a dict, it's not possible to have two entries with the same key. This is at odds with how the URL parameters are handled for multiselect fields, here the URL parameters would look like so:

?location_id=1&location_id=2

Passing the url parameters as a list also does not work:

{
    "location_id": [1,2]
}

This cause of the issue is similar to #12270. I believe setting doseq=True when calling urlencode would allow the above syntax to work, that is passing a list of values for the key with multiple values.

Originally created by @kkthxbye-code on GitHub (Apr 19, 2023). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.5.0-beta2 ### Python version 3.8 ### Steps to Reproduce 1. Create a new ObjectWidget list with the Model "DCIM > Device". 2. In the URL parameters filter by two different location_id's: ``` { "location_id": 1, "location_id": 2 } ``` 3. Save the widget ### Expected Behavior Widget should show devices belonging to either location with the id of 1 or 2. ### Observed Behavior Devices with location id 2 are shown. As the filters are passed as a JSON field and converted to a dict, it's not possible to have two entries with the same key. This is at odds with how the URL parameters are handled for multiselect fields, here the URL parameters would look like so: `?location_id=1&location_id=2` Passing the url parameters as a list also does not work: ``` { "location_id": [1,2] } ``` This cause of the issue is similar to #12270. I believe setting `doseq=True` when calling urlencode would allow the above syntax to work, that is passing a list of values for the key with multiple values.
adam added the type: bugstatus: acceptedbeta labels 2025-12-29 20:30:02 +01:00
adam closed this issue 2025-12-29 20:30:02 +01:00
Author
Owner

@jeremystretch commented on GitHub (Apr 21, 2023):

This has been fixed by adding doseq=True as suggested, but I wanted to also highlight that this is the correct format for the arguments:

{
    "location_id": [1, 2]
}
@jeremystretch commented on GitHub (Apr 21, 2023): This has been fixed by adding `doseq=True` as suggested, but I wanted to also highlight that this is the correct format for the arguments: ```json { "location_id": [1, 2] } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7924