mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 11:33:59 +03:00
DateField.to_representation unicode compatibility
This commit is contained in:
parent
057cf13578
commit
6b207d93d6
|
@ -1139,7 +1139,7 @@ class DateField(Field):
|
||||||
)
|
)
|
||||||
|
|
||||||
if output_format.lower() == ISO_8601:
|
if output_format.lower() == ISO_8601:
|
||||||
if (isinstance(value, str)):
|
if isinstance(value, six.string_types):
|
||||||
value = datetime.datetime.strptime(value, '%Y-%m-%d').date()
|
value = datetime.datetime.strptime(value, '%Y-%m-%d').date()
|
||||||
return value.isoformat()
|
return value.isoformat()
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ from decimal import Decimal
|
||||||
import django
|
import django
|
||||||
import pytest
|
import pytest
|
||||||
from django.http import QueryDict
|
from django.http import QueryDict
|
||||||
from django.utils import timezone
|
from django.utils import six, timezone
|
||||||
|
|
||||||
import rest_framework
|
import rest_framework
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
@ -895,6 +895,7 @@ class TestDateField(FieldValues):
|
||||||
outputs = {
|
outputs = {
|
||||||
datetime.date(2001, 1, 1): '2001-01-01',
|
datetime.date(2001, 1, 1): '2001-01-01',
|
||||||
'2001-01-01': '2001-01-01',
|
'2001-01-01': '2001-01-01',
|
||||||
|
six.text_type('2016-01-10'): '2016-01-10',
|
||||||
None: None,
|
None: None,
|
||||||
'': None,
|
'': None,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user