Opened 2 months ago

Last modified 2 months ago

#31636 assigned Bug

BooleanFieldListFilter doesn't respect field choices.

Reported by: Maxence G Owned by: Jithin Tom
Component: contrib.admin Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: yes UI/UX: no


If I have such construction:

class BoolTest(models.Model):
        (False, 'Pending'),
        (True, 'Bought')
    bought = models.BooleanField(
        verbose_name="Fancy Boolean",

class BoolTestAdmin(admin.ModelAdmin):
    list_filter = ('bought',), BoolTestAdmin)

The boolean Filter text is not modified to fit choices param

Example (in FR):

Par Fancy Boolean

  • Tout
  • Oui
  • Non

Should be :

Par Fancy Boolean

  • Tout
  • Bought
  • Pending

Change History (3)

comment:1 Changed 2 months ago by felixxm

Summary: Django Bool choices text and admin filterBooleanFieldListFilter doesn't respect field choices.
Triage Stage: UnreviewedAccepted
Version: 3.0master

Thanks, we could probably use field.flatchoices, e.g.

diff --git a/django/contrib/admin/ b/django/contrib/admin/
index 3e02cd89d7..9fdf038085 100644
--- a/django/contrib/admin/
+++ b/django/contrib/admin/
@@ -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]),

comment:2 Changed 2 months ago by Jithin Tom

Owner: changed from nobody to Jithin Tom
Status: newassigned

comment:3 Changed 2 months ago by felixxm

Has patch: set
Needs tests: set
Patch needs improvement: set
Note: See TracTickets for help on using tickets.
Back to Top