From bbc6da46fd36504e233d4d835908632785081f30 Mon Sep 17 00:00:00 2001 From: Yarden Sachs Date: Thu, 31 Jul 2025 21:21:12 -0700 Subject: [PATCH] Removed the redundant "All" option from MultipleDropdownFilter --- src/unfold/contrib/filters/admin/dropdown_filters.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/unfold/contrib/filters/admin/dropdown_filters.py b/src/unfold/contrib/filters/admin/dropdown_filters.py index dca34e2b7..c2c3fc10e 100644 --- a/src/unfold/contrib/filters/admin/dropdown_filters.py +++ b/src/unfold/contrib/filters/admin/dropdown_filters.py @@ -22,12 +22,19 @@ class DropdownFilter(admin.SimpleListFilter): all_option = ["", _("All")] def choices(self, changelist: ChangeList) -> tuple[dict[str, Any], ...]: + choices = [] + + if self.all_option: + choices = [self.all_option] + + choices.extend(self.lookup_choices) + return ( { "form": self.form_class( label=_(" By %(filter_title)s ") % {"filter_title": self.title}, name=self.parameter_name, - choices=[self.all_option, *self.lookup_choices], + choices=choices, data={self.parameter_name: self.value()}, multiple=self.multiple if hasattr(self, "multiple") else False, ), @@ -37,6 +44,7 @@ def choices(self, changelist: ChangeList) -> tuple[dict[str, Any], ...]: class MultipleDropdownFilter(DropdownFilter): multiple = True + all_option = None def __init__( self,