Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kkthxbye-code opened this issue Apr 19, 2023 · 1 comment
Assignees
Labels
beta Concerns a bug/feature in a beta release status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@kkthxbye-code
Copy link
Contributor

kkthxbye-code commented Apr 19, 2023

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.

@kkthxbye-code kkthxbye-code added type: bug A confirmed report of unexpected behavior in the application beta Concerns a bug/feature in a beta release labels Apr 19, 2023
@jeremystretch jeremystretch self-assigned this Apr 21, 2023
@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label Apr 21, 2023
@jeremystretch
Copy link
Member

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]
}

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beta Concerns a bug/feature in a beta release status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants