﻿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
19560	"Please improve warning message ""received a naive datetime while time zone support is active"""	Chris Wilson	nobody	"The warning message usually shows:

{{{
BadDataError: ('payment.Order', RuntimeWarning(u'DateTimeField received a naive datetime (2013-01-03 19:45:41.532391) while time zone support is active.',))
}}}

However it doesn't actually show which field this happened to, which makes it hard to debug without inserting breakpoints.

This three-line change to `django.db.models.fields.DateTimeField`:

{{{
    def get_prep_value(self, value):
        value = self.to_python(value)
        if value is not None and settings.USE_TZ and timezone.is_naive(value):
            ...
-            warnings.warn(""DateTimeField received a naive datetime (%s)""
-                          "" while time zone support is active."" % value,
+            warnings.warn(""DateTimeField %s.%s received a naive datetime (%s)""
+                          "" while time zone support is active."" %
+                          (self.model.__name__, self.name, value),
                          RuntimeWarning)
}}}

Which results in this output instead:

{{{
DateTimeField Order.created received a naive datetime (2013-01-03 20:11:24.084774) while time zone support is active.
}}}"	Cleanup/optimization	closed	Database layer (models, ORM)	1.4	Normal	fixed			Accepted	0	0	0	0	0	0
