[Django] #31590: Admin date_hierarchy crashes on datetime field with no data

13 views
Skip to first unread message

Django

unread,
May 14, 2020, 6:48:35 PM5/14/20
to django-...@googlegroups.com
#31590: Admin date_hierarchy crashes on datetime field with no data
-----------------------------------------+--------------------------------
Reporter: kjpc-tech | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.1
Severity: Normal | Keywords: date_hierarchy
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+--------------------------------
Just upgraded to Django 3.1 alpha and ran into this issue. It looks like
its related to commit 55cdf6c52db07f29128741b8734a523ed042e465. When there
is no data in the admin or all values are null, a date hierarchy on a
datetime field will cause a crash.


{{{
File "django/contrib/admin/templatetags/admin_list.py", line 386, in
date_hierarchy
for k, v in date_range.items()
File "django/contrib/admin/templatetags/admin_list.py", line 386, in
<dictcomp>
for k, v in date_range.items()
File "django/utils/timezone.py", line 212, in is_aware
return value.utcoffset() is not None

Exception Value: 'NoneType' object has no attribute 'utcoffset'
}}}


I'm starting work on a fix.

--
Ticket URL: <https://code.djangoproject.com/ticket/31590>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 14, 2020, 6:51:01 PM5/14/20
to django-...@googlegroups.com
#31590: Admin date_hierarchy crashes on datetime field with no data
--------------------------------+--------------------------------------
Reporter: kjpc-tech | Owner: kjpc-tech
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.1
Severity: Normal | Resolution:

Keywords: date_hierarchy | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by kjpc-tech):

* owner: nobody => kjpc-tech
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/31590#comment:1>

Django

unread,
May 14, 2020, 7:41:07 PM5/14/20
to django-...@googlegroups.com
#31590: Admin date_hierarchy crashes on datetime field with no data
--------------------------------+--------------------------------------
Reporter: Kyle | Owner: Kyle
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.1
Severity: Normal | Resolution:

Keywords: date_hierarchy | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by Kyle):

* has_patch: 0 => 1


Comment:

https://github.com/django/django/pull/12916

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

Django

unread,
May 14, 2020, 9:03:34 PM5/14/20
to django-...@googlegroups.com
#31590: Admin date_hierarchy crashes on datetime field with no data
-------------------------------------+-------------------------------------

Reporter: Kyle | Owner: Kyle
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.1
Severity: Release blocker | Resolution:
Keywords: date_hierarchy | 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 Simon Charette):

* severity: Normal => Release blocker
* stage: Unreviewed => Ready for checkin


Comment:

Patch LGTM pending two cosmetic adjustments.

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

Django

unread,
May 15, 2020, 1:07:35 AM5/15/20
to django-...@googlegroups.com
#31590: Admin date_hierarchy crashes on datetime field with no data
-------------------------------------+-------------------------------------
Reporter: Kyle | Owner: Kyle
Type: Bug | Status: closed
Component: contrib.admin | Version: 3.1
Severity: Release blocker | Resolution: fixed

Keywords: date_hierarchy | 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 Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"099bce1bf0b9802b7159beb9260b9b9e344bf497" 099bce1b]:
{{{
#!CommitTicketReference repository=""
revision="099bce1bf0b9802b7159beb9260b9b9e344bf497"
Fixed #31590 -- Fixed ModelAdmin.date_hierarchy crash with an empty
QuerySet.

Regression in 55cdf6c52db07f29128741b8734a523ed042e465.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31590#comment:4>

Django

unread,
May 15, 2020, 1:08:18 AM5/15/20
to django-...@googlegroups.com
#31590: Admin date_hierarchy crashes on datetime field with no data
-------------------------------------+-------------------------------------
Reporter: Kyle | Owner: Kyle
Type: Bug | Status: closed
Component: contrib.admin | Version: 3.1

Severity: Release blocker | Resolution: fixed
Keywords: date_hierarchy | 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 Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"ef19aec2caab1ad246fd48ba1cf7c02e05706a5d" ef19aec2]:
{{{
#!CommitTicketReference repository=""
revision="ef19aec2caab1ad246fd48ba1cf7c02e05706a5d"
[3.1.x] Fixed #31590 -- Fixed ModelAdmin.date_hierarchy crash with an
empty QuerySet.

Regression in 55cdf6c52db07f29128741b8734a523ed042e465.

Backport of 099bce1bf0b9802b7159beb9260b9b9e344bf497 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31590#comment:5>

Reply all
Reply to author
Forward
0 new messages