[Django] #23971: Allow filtering of None on null date fields

55 views
Skip to first unread message

Django

unread,
Dec 7, 2014, 4:34:57 PM12/7/14
to django-...@googlegroups.com
#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.

Django

unread,
Dec 7, 2014, 4:39:02 PM12/7/14
to django-...@googlegroups.com
#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 | Resolution:

Keywords: filter, admin | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* 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>

Django

unread,
Dec 10, 2014, 8:46:06 AM12/10/14
to django-...@googlegroups.com
#23971: Allow filtering of None on null date fields
-------------------------------+--------------------------------------
Reporter: rynomster | Owner: rynomster
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:

Keywords: filter, admin | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

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


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

Django

unread,
Dec 10, 2014, 8:46:20 AM12/10/14
to django-...@googlegroups.com
#23971: Allow filtering of None on null date fields
-------------------------------+--------------------------------------
Reporter: rynomster | Owner: rynomster
Type: New feature | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: fixed

Keywords: filter, admin | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

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


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

Django

unread,
Dec 10, 2014, 9:11:44 AM12/10/14
to django-...@googlegroups.com
#23971: Allow filtering of None on null date fields
-------------------------------+--------------------------------------
Reporter: rynomster | Owner: rynomster
Type: New feature | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:

Keywords: filter, admin | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* 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>

Django

unread,
Dec 10, 2014, 11:30:24 AM12/10/14
to django-...@googlegroups.com
#23971: Allow filtering of None on null date fields
-------------------------------+-------------------------------------
Reporter: rynomster | Owner: rynomster

Type: New feature | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: filter, admin | Triage Stage: Accepted

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

* 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>

Django

unread,
Feb 9, 2015, 1:55:32 AM2/9/15
to django-...@googlegroups.com
#23971: Allow filtering of None on null date fields
-------------------------------+-------------------------------------
Reporter: rynomster | Owner: rynomster
Type: New feature | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: filter, admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+-------------------------------------

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>

Django

unread,
Jan 14, 2016, 2:47:47 AM1/14/16
to django-...@googlegroups.com
#23971: Allow filtering of None on null date fields
-------------------------------+-------------------------------------
Reporter: rynomster | Owner: rynomster
Type: New feature | Status: assigned
Component: contrib.admin | Version: master

Severity: Normal | Resolution:
Keywords: filter, admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+-------------------------------------
Changes (by rynomster):

* status: new => assigned


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

Django

unread,
Jan 14, 2016, 3:39:30 AM1/14/16
to django-...@googlegroups.com
#23971: Allow filtering of None on null date fields
-------------------------------+-------------------------------------
Reporter: rynomster | Owner: rynomster
Type: New feature | Status: assigned
Component: contrib.admin | Version: master

Severity: Normal | Resolution:
Keywords: filter, admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+-------------------------------------

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>

Django

unread,
Feb 2, 2016, 7:41:35 AM2/2/16
to django-...@googlegroups.com
#23971: Allow filtering of None on null date fields
-------------------------------+-------------------------------------
Reporter: rynomster | Owner: rynomster
Type: New feature | Status: assigned
Component: contrib.admin | Version: master

Severity: Normal | Resolution:
Keywords: filter, admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* needs_better_patch: 1 => 0


Comment:

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

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

Django

unread,
Feb 2, 2016, 12:05:25 PM2/2/16
to django-...@googlegroups.com
#23971: Allow list filter filtering of None on null date fields
-------------------------------------+-------------------------------------

Reporter: rynomster | Owner: rynomster
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: filter, admin | Triage Stage: Ready for
| checkin

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

* stage: Accepted => Ready for checkin


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

Django

unread,
Feb 2, 2016, 12:06:52 PM2/2/16
to django-...@googlegroups.com
#23971: Allow list filter filtering of None on null date fields
-------------------------------------+-------------------------------------
Reporter: rynomster | Owner: rynomster
Type: New feature | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: fixed

Keywords: filter, admin | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* 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>

Django

unread,
Feb 2, 2016, 1:04:38 PM2/2/16
to django-...@googlegroups.com
#23971: Allow list filter filtering of None on null date fields
-------------------------------------+-------------------------------------
Reporter: rynomster | Owner: rynomster
Type: New feature | Status: closed
Component: contrib.admin | Version: master

Severity: Normal | Resolution: fixed
Keywords: filter, admin | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Feb 2, 2016, 1:28:55 PM2/2/16
to django-...@googlegroups.com
#23971: Allow list filter filtering of None on null date fields
-------------------------------------+-------------------------------------
Reporter: rynomster | Owner: rynomster
Type: New feature | Status: closed
Component: contrib.admin | Version: master

Severity: Normal | Resolution: fixed
Keywords: filter, admin | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Feb 3, 2016, 5:42:44 AM2/3/16
to django-...@googlegroups.com
#23971: Allow list filter filtering of None on null date fields
-------------------------------------+-------------------------------------
Reporter: rynomster | Owner: rynomster
Type: New feature | Status: closed
Component: contrib.admin | Version: master

Severity: Normal | Resolution: fixed
Keywords: filter, admin | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Reply all
Reply to author
Forward
0 new messages