Added a missing warning forgotten in r17392.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17393 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel 2012-01-24 10:32:28 +00:00
parent 8f168976d6
commit 0907233040
1 changed files with 7 additions and 0 deletions

View File

@ -750,6 +750,13 @@ class DateTimeField(DateField):
if isinstance(value, datetime.date): if isinstance(value, datetime.date):
value = datetime.datetime(value.year, value.month, value.day) value = datetime.datetime(value.year, value.month, value.day)
if settings.USE_TZ: if settings.USE_TZ:
# For backwards compatibility, interpret naive datetimes in
# local time. This won't work during DST change, but we can't
# do much about it, so we let the exceptions percolate up the
# call stack.
warnings.warn(u"DateTimeField received a naive datetime (%s)"
u" while time zone support is active." % value,
RuntimeWarning)
default_timezone = timezone.get_default_timezone() default_timezone = timezone.get_default_timezone()
value = timezone.make_aware(value, default_timezone) value = timezone.make_aware(value, default_timezone)
return value return value