Skip to content

fix: filtered choices get lost when search used after filtering #999

@sezginacer

Description

@sezginacer

What version of Unfold are you using?

main

What version of Django are you using?

5.1

What browser are you using?

Firefox 135.0

Did you checked changelog/commit history, if the bug is not already fixed?

Yes

Did you searched other issues, if the bug is not already fixed?

Yes

Did you checked documentation?

Yes

Are you able to replicate the bug in the demo site?

No, I could not find MultipleDropdownFilter or MultipleRelatedDropdownFilter on demo site.

Repository with reproduced bug

No

Describe your issue

Suppose we have an admin class like below.

@admin.register(SampleModel)
class SampleModelAdmin(ModelAdmin):
    list_filter = [
        ("status", MultipleDropdownFilter), 
        ("owner", MultipleRelatedDropdownFilter),
        ("writer", MultipleRelatedDropdownFilter),
    ]
  • Go to change_list page.
  • Choose some filters and apply. Then let's say, current URL after filtering is /admin/app/model/?status=open&status=closed&owner__id__exact=1&owner__id__exact=2&owner__id__exact=3&writer__id__exact=5
  • Write 'test' to search form & click enter. Current URL after search is /admin/app/model/?q=test&status=open&owner__id__exact=1&writer__id__exact=5
  • So, status=closed and owner__id__exact=2&owner__id__exact=3 filters get lost.

While just filtering (not searching), there is no problem like this one. But filter a field with multiple values then searching breaks query string & filters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions