Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
6b207d93
Commit
6b207d93
authored
Jan 10, 2016
by
Mikalai Radchuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DateField.to_representation unicode compatibility
parent
057cf135
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
2 deletions
+3
-2
rest_framework/fields.py
+1
-1
tests/test_fields.py
+2
-1
No files found.
rest_framework/fields.py
View file @
6b207d93
...
@@ -1139,7 +1139,7 @@ class DateField(Field):
...
@@ -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
()
...
...
tests/test_fields.py
View file @
6b207d93
...
@@ -6,7 +6,7 @@ from decimal import Decimal
...
@@ -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):
...
@@ -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
,
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment