Skip to content

Conversation

@dases
Copy link

@dases dases commented Jun 28, 2025

Ad-hoc filters (ie, those not declared in list_filter) is broken when using Django 5+.

Such filtering is supported when using Django 4x (also, it's supported by current Django 5+ ModelAdmin).

The issue is that we are passing around a QueryDict of query params in IndexView, and in some places calling .items() on it, which has a flattening affect on values.

This means that, for an undeclared query param:

  • the get_filters method returns only the last value for a multi-value query, and
  • the get_queryset passes a dict[str, str] to build_q_object_from_lookup_parameters Django util, which treats the value part of .items() as a list.

The latter means that a string value gets treated as a list that is OR'd:
E.g. given a query param: location=Hobart, we get a queryset with WHERE location='H' OR location='o' OR location='b'...

The tests that accompanied support for multi-valued query params did not capture this because the filter being tested is declared in list_filter. wagtail/wagtail#10242

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.

1 participant