Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#31590 closed Bug (fixed)

Admin date_hierarchy crashes on datetime field with no data

Reported by: Kyle Owned by: Kyle
Component: contrib.admin Version: 3.1
Severity: Release blocker Keywords: date_hierarchy
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

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.

Change History (5)

comment:1 by Kyle, 4 years ago

Owner: changed from nobody to Kyle
Status: newassigned

comment:3 by Simon Charette, 4 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedReady for checkin

Patch LGTM pending two cosmetic adjustments.

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 099bce1b:

Fixed #31590 -- Fixed ModelAdmin.date_hierarchy crash with an empty QuerySet.

Regression in 55cdf6c52db07f29128741b8734a523ed042e465.

comment:5 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In ef19aec2:

[3.1.x] Fixed #31590 -- Fixed ModelAdmin.date_hierarchy crash with an empty QuerySet.

Regression in 55cdf6c52db07f29128741b8734a523ed042e465.

Backport of 099bce1bf0b9802b7159beb9260b9b9e344bf497 from master

Note: See TracTickets for help on using tickets.
Back to Top