#26277: The list_display for CharField doesn't work for None value among choices
-------------------------------+-----------------------------------------
Reporter: PetrDlouhy | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 1.9
Severity: Normal | Keywords: list_filter CharField admin
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------+-----------------------------------------
I have a following model field:
{{{
DIRECTIONS = [
('trip_to', "From"),
('trip_from', "To"),
(None, "None"),
('', "-"),
]
direction = models.CharField(
verbose_name="direction",
choices=DIRECTIONS,
max_length=20,
null=True, blank=True)
}}}
I want to filter out the items with direction set to Null in my admin list
display. Both the choices (`None` and `''`) are displayed in the filter,
but none of them works. The None choice generates URL without the
`direction__exact` parameter. The `''` choice generates
`direction__exact=` parameter, which also does not work.
What work is, if I set the URL parameter manually to
`direction__isnull=True`, but the link is not generated that way.
My suggestion is, that when the CharField has `null=True` and
`blank=True`, then there is always ''Unknown'' choice in `list_filter` and
if the `None` or `''` is in choices, than the choice is named that way.
--
Ticket URL: <https://code.djangoproject.com/ticket/26277>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/053.2c90b90476b331e31811d91d88930f68%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.