#23971 closed New feature (fixed)
Allow list filter filtering of None on null date fields
| Reported by: | Ryno | Owned by: | Ryno |
|---|---|---|---|
| Component: | contrib.admin | Version: | dev |
| Severity: | Normal | Keywords: | filter, admin |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
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)
Change History (14)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:3 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
comment:4 by , 11 years ago
| Has patch: | set |
|---|---|
| Resolution: | fixed |
| Status: | closed → new |
Ticket is not fixed until code is merged.
comment:5 by , 11 years ago
| Easy pickings: | unset |
|---|---|
| Patch needs improvement: | set |
| Triage Stage: | Unreviewed → Accepted |
This seems okay, although it might make the UI a bit confusing because the distinction between 'Any date' and 'Has date' isn't so clear.
The patch can be cleaned up a bit if you work through our patch review checklist.
comment:6 by , 11 years ago
Thanks timgraham, sorry I thought I would get a notification or something about this... will clean it up
comment:7 by , 10 years ago
| Status: | new → assigned |
|---|
comment:8 by , 10 years ago
I've reworded a bit it, I hope that looks better?
I looked at the guidelines, and I can't really find a fault?
I'll be happy to clean it up. Maybe I should change it a bit, and have
self.lookup_kwarg_isnull = '%s__isnull' % field_path
comment:10 by , 10 years ago
| Summary: | Allow filtering of None on null date fields → Allow list filter filtering of None on null date fields |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
follow-up: 12 comment:11 by , 10 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
In 468d8211:
comment:12 by , 10 years ago
Replying to Tim Graham <timograham@…>:
In 468d8211:
I just thought I'd bring up a previous comment, about clearer distinction:
Replying to timgraham:
This seems okay, although it might make the UI a bit confusing because the distinction between 'Any date' and 'Has date' isn't so clear.
The patch can be cleaned up a bit if you work through our patch review checklist.
That's the main reason I went for Has valid date.
follow-up: 14 comment:13 by , 10 years ago
Oh, "Has valid date" left me wondering how/if something could have an "invalid" date.
comment:14 by , 10 years ago
Replying to timgraham:
Oh, "Has valid date" left me wondering how/if something could have an "invalid" date.
Oic :) thanks Tim!
Changes committed: https://github.com/django/django/pull/3705