Skip to content

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.

<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?

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. 🤔

Copy link
Author

Choose a reason for hiding this comment

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

The idea is that all input would work, not just QueryArrays. Also ?price=1,2. QueryArray only supports ?price=1,price=2.

@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

@gabn88
Copy link
Author

gabn88 commented Oct 16, 2025

@carltongibson I know you are very busy, but do you a minute to express your feelings about this MR? It would solve some frontend head-aches.
Now they have to do:

__in: objects ? [objects?.map(object => object.id).join(',')] : undefined,

whereas otherwise it would be:

__in: objects?.map(object => object.id),`

apart from code cleanliness it is hard for the frontend to find out when they have to use which filter type, it will simply be omitted if you choose the wrong type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants