﻿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
33200	"Consider ""hiding"" datetime/zoneinfo imports in django.utils.timezone"	Jaap Roes	nobody	"During code review I've seen people using `from django.utils.timezone import datetime` (and variations) on multiple occasions. Sometimes because their IDE just autocompletes that import, sometimes under the false assumption that these are a timezone aware variation of the stdlib's datetime implementation.

The most recent iteration I came across can be seen here: https://github.com/SmileyChris/easy-thumbnails/pull/579#discussion_r729003666

Because importing `datetime`, `timedelta`, `zoneinfo` etc. from a module called `timezone` ""looks"" reasonable people seem to assume that these are valid imports and sometimes even assume these are Django specific implementations.

An easy way to discourage these imports is aliasing them, i.e.:

{{{
import datetime as _datetime
import zoneinfo as _zoneinfo
}}}

I'm aware Django (or any Python project) is full of potential incorrect import opportunities. But this one seems to pop up fairly regularly in my experience and when combined with incorrect assumptions about what is being imported can be a root cause of subtle bugs."	Cleanup/optimization	closed	Utilities	dev	Normal	wontfix	timezone datetime		Unreviewed	0	0	0	0	0	0
