convert datetimes to the appropriate timezone on their way out

This commit is contained in:
Tim Saylor 2015-07-09 13:01:19 -05:00
parent a825098440
commit 48e75379c1

View File

@ -941,6 +941,11 @@ class DateTimeField(Field):
self.fail('invalid', format=humanized_format)
def to_representation(self, value):
if timezone.is_aware(value):
# convert the datetime to the timezone the user is expecting
tz = getattr(timezone._active, "value", self.default_timezone)
value = timezone.localtime(value, tz)
if self.format is None:
return value