#31636: BooleanFieldListFilter doesn't respect field choices. -------------------------------+------------------------------------ Reporter: Maxence G | Owner: nobody Type: Bug | Status: new Component: contrib.admin | Version: master Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 1 | UI/UX: 0 -------------------------------+------------------------------------ Changes (by felixxm):
* version: 3.0 => master * stage: Unreviewed => Accepted Comment: Thanks, we could probably use `field.flatchoices`, e.g. {{{ diff --git a/django/contrib/admin/filters.py b/django/contrib/admin/filters.py index 3e02cd89d7..9fdf038085 100644 --- a/django/contrib/admin/filters.py +++ b/django/contrib/admin/filters.py @@ -244,10 +244,7 @@ class BooleanFieldListFilter(FieldListFilter): return [self.lookup_kwarg, self.lookup_kwarg2] def choices(self, changelist): - for lookup, title in ( - (None, _('All')), - ('1', _('Yes')), - ('0', _('No'))): + for lookup, title in ((None, _('All')), *self.field.flatchoices): yield { 'selected': self.lookup_val == lookup and not self.lookup_val2, 'query_string': changelist.get_query_string({self.lookup_kwarg: lookup}, [self.lookup_kwarg2]), }}} -- Ticket URL: <https://code.djangoproject.com/ticket/31636#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.947c61cf6ecc6b1b1e5ecfbf47cc680f%40djangoproject.com.