Re: [Django] #37263: Admin changelist search crashes (500) on `__exact` search_fields with choices

3 views
Skip to first unread message

Django

unread,
Aug 12, 2026, 4:50:15 PM (11 days ago) Aug 12
to django-...@googlegroups.com
#37263: Admin changelist search crashes (500) on `__exact` search_fields with
choices
---------------------------------+----------------------------------------
Reporter: Adam Johnson | Owner: Adam Johnson
Type: Bug | Status: assigned
Component: contrib.admin | Version: 6.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
---------------------------------+----------------------------------------
Comment (by Adam Johnson):

> BooleanField: The commit message explains that there is an increase in
search permissiveness for values that can be normalized by
formfield.to_python(). So for me, the permissive matching on truthy values
is fine.

Did you understand that a search for an arbitrary string now matches every
row where any boolean field is true? That’s a huge regression to me.
Previously, you'd need to serach for `true` to match truthy rows only.

Try running the new tests on the current `main`:
https://github.com/django/django/pull/21754/changes#diff-
640602cc17dc3e9a26db47f58b40a1289d5c0f1b5b0fe547810b1d962f6cde8bR996

> TypedChoiceField: I think this use case gives us a reason to reopen
#34156, which, when you connect the dots a little further, says that
TypedChoiceField is violating the contract that to_python() should return
the correct python types.

Oh yeah, that’s a problem! Thanks for looking into it.
--
Ticket URL: <https://code.djangoproject.com/ticket/37263#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 13, 2026, 6:24:05 AM (11 days ago) Aug 13
to django-...@googlegroups.com
#37263: Admin changelist search crashes (500) on `__exact` search_fields with
choices
---------------------------------+----------------------------------------
Reporter: Adam Johnson | Owner: Adam Johnson
Type: Bug | Status: assigned
Component: contrib.admin | Version: 6.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
---------------------------------+----------------------------------------
Comment (by Jacob Walls):

Replying to [comment:3 Adam Johnson]:
> Did you understand that a search for an arbitrary string now matches
every row where any boolean field is true? That’s a huge regression to me.
Previously, you'd need to serach for `true` to match truthy rows only.


Ah, no, I didn't contemplate the effect of all the terms being OR'd
together, so thanks for connecting those dots for me. Agree we have to do
something! Probably a distinct formfield for search. Mabye with an
overridable datastructure to hold it so that it doesn't overload
`self.formfield_for_dbfield`?
--
Ticket URL: <https://code.djangoproject.com/ticket/37263#comment:4>

Django

unread,
Aug 18, 2026, 3:36:59 PM (5 days ago) Aug 18
to django-...@googlegroups.com
#37263: Admin changelist search crashes (500) on `__exact` search_fields with
choices
---------------------------------+----------------------------------------
Reporter: Adam Johnson | Owner: Adam Johnson
Type: Bug | Status: assigned
Component: contrib.admin | Version: 6.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+----------------------------------------
Changes (by Jacob Walls):

* needs_better_patch: 1 => 0

Comment:

I pushed a couple proposed tweaks to reduce the types of exceptions
caught, and to push the special cases out of inline logic and into custom
form classes where possible. It's ready for opinions.
--
Ticket URL: <https://code.djangoproject.com/ticket/37263#comment:5>

Django

unread,
Aug 19, 2026, 12:11:22 PM (4 days ago) Aug 19
to django-...@googlegroups.com
#37263: Admin changelist search crashes (500) on `__exact` search_fields with
choices
---------------------------------+----------------------------------------
Reporter: Adam Johnson | Owner: Adam Johnson
Type: Bug | Status: assigned
Component: contrib.admin | Version: 6.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
---------------------------------+----------------------------------------
Changes (by Jacob Walls):

* needs_better_patch: 0 => 1

Comment:

Should probably look into making `ChangeList.search_form_class` more
field-granular.
--
Ticket URL: <https://code.djangoproject.com/ticket/37263#comment:6>

Django

unread,
Aug 19, 2026, 6:11:39 PM (4 days ago) Aug 19
to django-...@googlegroups.com
#37263: Admin changelist search crashes (500) on `__exact` search_fields with
choices
---------------------------------+----------------------------------------
Reporter: Adam Johnson | Owner: Adam Johnson
Type: Bug | Status: assigned
Component: contrib.admin | Version: 6.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+----------------------------------------
Changes (by Jacob Walls):

* needs_better_patch: 1 => 0

Comment:

Replying to [comment:6 Jacob Walls]:
> Should probably look into making `ChangeList.search_form_class` more
field-granular.

Never mind, this idea turned out to be awkward, since `def
get_search_results` is on `ModelAdmin` itself, so this would introduce a
two-way reference back to the `ChangeList`.
--
Ticket URL: <https://code.djangoproject.com/ticket/37263#comment:7>
Reply all
Reply to author
Forward
0 new messages