{{{
# 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.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Changes committed: [https://github.com/django/django/pull/3705]
--
Ticket URL: <https://code.djangoproject.com/ticket/23971#comment:1>
* owner: nobody => rynomster
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/23971#comment:2>
* status: assigned => closed
* resolution: => fixed
--
Ticket URL: <https://code.djangoproject.com/ticket/23971#comment:3>
* status: closed => new
* has_patch: 0 => 1
* resolution: fixed =>
Comment:
Ticket is not fixed until code is merged.
--
Ticket URL: <https://code.djangoproject.com/ticket/23971#comment:4>
* needs_better_patch: 0 => 1
* easy: 1 => 0
* stage: Unreviewed => Accepted
Comment:
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
[https://docs.djangoproject.com/en/dev/internals/contributing/writing-code
/submitting-patches/#patch-review-checklist patch review checklist].
--
Ticket URL: <https://code.djangoproject.com/ticket/23971#comment:5>
Comment (by rynomster):
Thanks timgraham, sorry I thought I would get a notification or something
about this... will clean it up
--
Ticket URL: <https://code.djangoproject.com/ticket/23971#comment:6>
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/23971#comment:7>
Comment (by rynomster):
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
{{{#!python
self.lookup_kwarg_isnull = '%s__isnull' % field_path
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/23971#comment:8>
* needs_better_patch: 1 => 0
Comment:
[https://github.com/django/django/pull/5980 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/23971#comment:9>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/23971#comment:10>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"468d8211df999845607c3bb163c859e428d39dea" 468d8211]:
{{{
#!CommitTicketReference repository=""
revision="468d8211df999845607c3bb163c859e428d39dea"
Fixed #23971 -- Added "Has date"/"No date" choices for
DateFieldListFilter.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/23971#comment:11>
Comment (by rynomster):
Replying to [comment:11 Tim Graham <timograham@…>]:
> In [changeset:"468d8211df999845607c3bb163c859e428d39dea" 468d8211]:
> {{{
> #!CommitTicketReference repository=""
revision="468d8211df999845607c3bb163c859e428d39dea"
> Fixed #23971 -- Added "Has date"/"No date" choices for
DateFieldListFilter.
> }}}
I just thought I'd bring up a previous comment, about clearer distinction:
Replying to [comment:5 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
[https://docs.djangoproject.com/en/dev/internals/contributing/writing-code
/submitting-patches/#patch-review-checklist patch review checklist].
That's the main reason I went for Has valid date.
--
Ticket URL: <https://code.djangoproject.com/ticket/23971#comment:12>
Comment (by timgraham):
Oh, "Has valid date" left me wondering how/if something could have an
"invalid" date.
--
Ticket URL: <https://code.djangoproject.com/ticket/23971#comment:13>
Comment (by rynomster):
Replying to [comment:13 timgraham]:
> Oh, "Has valid date" left me wondering how/if something could have an
"invalid" date.
Oic :) thanks Tim!
--
Ticket URL: <https://code.djangoproject.com/ticket/23971#comment:14>