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
9406e45b
Commit
9406e45b
authored
Jun 14, 2016
by
Tom Christie
Committed by
GitHub
Jun 14, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass through strings as-in with DateTimeField (#4196)
parent
1633a0a2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
rest_framework/fields.py
+2
-4
tests/test_fields.py
+2
-0
No files found.
rest_framework/fields.py
View file @
9406e45b
...
...
@@ -1073,7 +1073,7 @@ class DateTimeField(Field):
output_format
=
getattr
(
self
,
'format'
,
api_settings
.
DATETIME_FORMAT
)
if
output_format
is
None
:
if
output_format
is
None
or
isinstance
(
value
,
six
.
string_types
)
:
return
value
if
output_format
.
lower
()
==
ISO_8601
:
...
...
@@ -1133,7 +1133,7 @@ class DateField(Field):
output_format
=
getattr
(
self
,
'format'
,
api_settings
.
DATE_FORMAT
)
if
output_format
is
None
:
if
output_format
is
None
or
isinstance
(
value
,
six
.
string_types
)
:
return
value
# Applying a `DateField` to a datetime value is almost always
...
...
@@ -1146,8 +1146,6 @@ class DateField(Field):
)
if
output_format
.
lower
()
==
ISO_8601
:
if
isinstance
(
value
,
six
.
string_types
):
value
=
datetime
.
datetime
.
strptime
(
value
,
'
%
Y-
%
m-
%
d'
)
.
date
()
return
value
.
isoformat
()
return
value
.
strftime
(
output_format
)
...
...
tests/test_fields.py
View file @
9406e45b
...
...
@@ -993,6 +993,8 @@ class TestDateTimeField(FieldValues):
outputs
=
{
datetime
.
datetime
(
2001
,
1
,
1
,
13
,
00
):
'2001-01-01T13:00:00'
,
datetime
.
datetime
(
2001
,
1
,
1
,
13
,
00
,
tzinfo
=
timezone
.
UTC
()):
'2001-01-01T13:00:00Z'
,
'2001-01-01T00:00:00'
:
'2001-01-01T00:00:00'
,
six
.
text_type
(
'2016-01-10T00:00:00'
):
'2016-01-10T00:00:00'
,
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