added utc compat to fields

This commit is contained in:
Asif Saifuddin Auvi 2017-01-18 19:31:04 +06:00
parent 5717e853db
commit bc3849bd59

View File

@ -32,7 +32,7 @@ from django.utils.translation import ugettext_lazy as _
from rest_framework import ISO_8601 from rest_framework import ISO_8601
from rest_framework.compat import ( from rest_framework.compat import (
get_remote_field, unicode_repr, unicode_to_repr, value_from_object get_remote_field, unicode_repr, unicode_to_repr, value_from_object, utc
) )
from rest_framework.exceptions import ErrorDetail, ValidationError from rest_framework.exceptions import ErrorDetail, ValidationError
from rest_framework.settings import api_settings from rest_framework.settings import api_settings
@ -1104,7 +1104,7 @@ class DateTimeField(Field):
if (field_timezone is not None) and not timezone.is_aware(value): if (field_timezone is not None) and not timezone.is_aware(value):
return timezone.make_aware(value, field_timezone) return timezone.make_aware(value, field_timezone)
elif (field_timezone is None) and timezone.is_aware(value): elif (field_timezone is None) and timezone.is_aware(value):
return timezone.make_naive(value, timezone.UTC()) return timezone.make_naive(value, utc)
return value return value
def default_timezone(self): def default_timezone(self):