[Django] #31636: Django Bool choices text and admin filter

21 views
Skip to first unread message

Django

unread,
May 28, 2020, 6:38:32 AM5/28/20
to django-...@googlegroups.com
#31636: Django Bool choices text and admin filter
-----------------------------------------+------------------------
Reporter: Maxence G | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-----------------------------------------+------------------------
If I have such construction:
{{{
# models.py
class BoolTest(models.Model):
BOUGHT_CHOICES = (
(False, 'Pending'),
(True, 'Bought')
)
bought = models.BooleanField(
verbose_name="Fancy Boolean",
default=False,
choices=BOUGHT_CHOICES)

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

admin.site.register(BoolTest, BoolTestAdmin)
}}}

The boolean Filter text is not modified to fit choices param

Example (in FR):

**FILTRE**
Par Fancy Boolean
- Tout
- Oui
- Non

Should be :

**FILTRE**
Par Fancy Boolean
- Tout
- Bought
- Pending

--
Ticket URL: <https://code.djangoproject.com/ticket/31636>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 28, 2020, 3:41:07 PM5/28/20
to django-...@googlegroups.com
#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

unread,
Jun 4, 2020, 12:13:41 PM6/4/20
to django-...@googlegroups.com
#31636: BooleanFieldListFilter doesn't respect field choices.
-------------------------------+--------------------------------------
Reporter: Maxence G | Owner: jithintomz
Type: Bug | Status: assigned

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 jithintomz):

* owner: nobody => jithintomz
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/31636#comment:2>

Django

unread,
Jun 11, 2020, 4:13:34 AM6/11/20
to django-...@googlegroups.com
#31636: BooleanFieldListFilter doesn't respect field choices.
-------------------------------+--------------------------------------
Reporter: Maxence G | Owner: Jithin Tom

Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* needs_tests: 0 => 1


Comment:

[https://github.com/django/django/pull/13047 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/31636#comment:3>

Django

unread,
Sep 6, 2020, 8:27:45 PM9/6/20
to django-...@googlegroups.com
#31636: BooleanFieldListFilter doesn't respect field choices.
-------------------------------+-----------------------------------------
Reporter: Maxence G | Owner: Ninad Kulkrni

Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------+-----------------------------------------

Comment (by Manav Agarwal):

May i work on this issue?

--
Ticket URL: <https://code.djangoproject.com/ticket/31636#comment:5>

Django

unread,
Sep 8, 2020, 6:07:59 PM9/8/20
to django-...@googlegroups.com
#31636: BooleanFieldListFilter doesn't respect field choices.
-------------------------------+-----------------------------------------
Reporter: Maxence G | Owner: Manav Agarwal

Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------+-----------------------------------------
Changes (by Manav Agarwal):

* owner: Ninad Kulkrni => Manav Agarwal


--
Ticket URL: <https://code.djangoproject.com/ticket/31636#comment:6>

Django

unread,
Sep 14, 2020, 2:12:13 AM9/14/20
to django-...@googlegroups.com
#31636: BooleanFieldListFilter doesn't respect field choices.
-------------------------------+-----------------------------------------
Reporter: Maxence G | Owner: Manav Agarwal
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+-----------------------------------------
Changes (by felixxm):

* needs_better_patch: 1 => 0
* needs_tests: 1 => 0


Comment:

[https://github.com/django/django/pull/13413 New PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/31636#comment:7>

Django

unread,
Sep 14, 2020, 8:18:31 AM9/14/20
to django-...@googlegroups.com
#31636: BooleanFieldListFilter doesn't respect field choices.
-------------------------------+-----------------------------------------
Reporter: Maxence G | Owner: Manav Agarwal
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------+-----------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/31636#comment:8>

Django

unread,
Sep 15, 2020, 3:18:41 AM9/15/20
to django-...@googlegroups.com
#31636: BooleanFieldListFilter doesn't respect field choices.
-------------------------------------+-------------------------------------

Reporter: Maxence G | Owner: Manav
| Agarwal
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/31636#comment:9>

Django

unread,
Sep 15, 2020, 4:19:01 AM9/15/20
to django-...@googlegroups.com
#31636: BooleanFieldListFilter doesn't respect field choices.
-------------------------------------+-------------------------------------
Reporter: Maxence G | Owner: Manav
| Agarwal
Type: Bug | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"580a4341cb0b4cbfc215a70afc004875a7e815f4" 580a4341]:
{{{
#!CommitTicketReference repository=""
revision="580a4341cb0b4cbfc215a70afc004875a7e815f4"
Fixed #31636 -- Made BooleanFieldListFilter respect Field.choices.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31636#comment:10>

Reply all
Reply to author
Forward
0 new messages