﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18323	Date-based generic views mix dates and datetimes unsafely	Aymeric Augustin	Aymeric Augustin	"Date-based generic views can use either a !DateField or a !DateTimeField. But the logic of the lookups to handle these two cases is a bit fuzzy. When time zone support is enabled, it isn't correct (or at least, not obviously so).

In order to make the code less fragile, I rewrote much of the interval handling logic.

This patch:
- adds some explicit conversions between dates and datetimes, accounting for the current time zone,
- makes the code generally clearer and possibly more correct — off-by-the-UTC-offset bugs are less likely when `USE_TZ = True`.

As a side effect, this patch is likely to fix two bugs:
- an egde case where accessing next_day/week/month/year on a !DateTimeField could 404 even with allow_empty = False due to approximative filtering,
- #17192.

"	Cleanup/optimization	closed	Generic views	dev	Normal	fixed	refactoring		Accepted	1	0	0	0	0	0
