mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[1.6.x] Fixed #19560 -- Identified field in warning for naive datetime.
Thanks gcc for the report and vajrasky for the patch.
Backport of 570d9c2678 from master.
This commit is contained in:
@@ -842,8 +842,9 @@ class DateTimeField(DateField):
|
||||
# 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("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)
|
||||
default_timezone = timezone.get_default_timezone()
|
||||
value = timezone.make_aware(value, default_timezone)
|
||||
@@ -896,8 +897,9 @@ class DateTimeField(DateField):
|
||||
# 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("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)
|
||||
default_timezone = timezone.get_default_timezone()
|
||||
value = timezone.make_aware(value, default_timezone)
|
||||
|
||||
Reference in New Issue
Block a user