Skip to content
New issue

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

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

Already on GitHub? # to your account

QueryArrayWidget does not work with the foo=bar,baz syntax #1685 #1686

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

gabn88
Copy link

@gabn88 gabn88 commented Sep 6, 2024

This is the failing test.

@gabn88
Copy link
Author

gabn88 commented Nov 20, 2024

What should I do to get this merged in?

Copy link
Owner

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not following the desire here. The QueryArrayWidget is for old PHP-style price[] query string parameters.

@@ -526,11 +527,14 @@ def test_widget(self):
<input type="text" name="price" value="1,2" />""",
)

import django.http
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this import here?

@@ -595,3 +599,7 @@ def test_widget_value_from_datadict(self):

result = w.value_from_datadict({}, {}, "price")
self.assertEqual(result, [])

data = QueryDict("price=1,2")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a query array example. 🤔

@gabn88
Copy link
Author

gabn88 commented Nov 21, 2024

Thanks for the review! Will update the PR.

The reason for this PR is that:

  1. The ModelMultipleChoiceFilter expects an ?a=x&a=y search filter
  2. The __in expects an ?a=x,y search filter

This makes it hard for the frontend to know when to use which and also the frontend like to use ?a=x,y also for the ModelMultipleChoiceFilter.

With this fixes, you can in both cases use a QueryArrayWidget and all three search filters, for all types of filtering that uses multiple entries (whether __in or ModelMultipleChoiceFilter):

  1. a=x&a=y
  2. a=x,y
  3. a[]=x,y

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants