#23971: Allow filtering of None on null date fields
-------------------------------+---------------------------
Reporter: rynomster | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Keywords: filter, admin
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+---------------------------
Currently I'm overriding the DateFieldListFilter, but I think it should
possibly be in Django?
{{{
# Override Datefield filter (add None)
from django.contrib.admin.filters import FieldListFilter,
DateFieldListFilter
class DateFieldListFilter(DateFieldListFilter):
def __init__(self, field, request, params, model, model_admin,
field_path):
super(DateFieldListFilter, self).__init__(field, request, params,
model, model_admin, field_path)
if field.null:
self.links += (
(_('None'), {
self.field_generic + 'isnull': str(True),
}),
(_('Not None'), {
self.field_generic + 'isnull': str(False),
}),
)
FieldListFilter.register(
lambda f: isinstance(f, models.DateField), DateFieldListFilter, True)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/23971>
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/052.9869764a48fdef68c0f86c9c04839e76%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.