Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#19370 closed Bug (fixed)

date filter returns empty string for midnight

Reported by: dbrgn Owned by: nobody
Component: Template system Version: 1.4
Severity: Normal Keywords:
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


Python considers midnight (datetime.time(0, 0)) to be False. The date template filter stumbles over this.

When using {{ midnight|date:"H:i" }}, Django returns an empty string.

See for discussion about the bug.

I'll post a pull request with the fix on Github in a short while.

Change History (4)

comment:1 Changed 4 years ago by dbrgn

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Pull request is here:

This is already fixed in the |time filter, but not in the |date filter which can also be used to format times.

Regression tests are provided.

comment:2 Changed 4 years ago by claudep

  • Triage Stage changed from Unreviewed to Ready for checkin

comment:3 Changed 4 years ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from new to closed

In c10aaa70a4cc2e567dc29953f33f0a4219717d61:

Fixed #19370 -- Made date filter properly handle midnight value

comment:4 Changed 4 years ago by Claude Paroz <claude@…>

In 5509eb862668ebeadd52248e2af124dfce2cce72:

[1.5.x] Fixed #19370 -- Made date filter properly handle midnight value

Backport of c10aaa70a from master.

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