aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/fields.py
diff options
context:
space:
mode:
Diffstat (limited to 'rest_framework/fields.py')
-rw-r--r--rest_framework/fields.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py
index 87e0161f..e65f0307 100644
--- a/rest_framework/fields.py
+++ b/rest_framework/fields.py
@@ -496,6 +496,8 @@ class DateField(WritableField):
raise ValidationError(msg)
def to_native(self, value):
+ if isinstance(value, datetime.datetime):
+ value = value.date()
if self.output_format.lower() == ISO8601:
return value.isoformat()
return value.strftime(self.output_format)
@@ -611,6 +613,8 @@ class TimeField(WritableField):
raise ValidationError(msg)
def to_native(self, value):
+ if isinstance(value, datetime.datetime):
+ value = value.time()
if self.output_format.lower() == ISO8601:
return value.isoformat()
return value.strftime(self.output_format)