Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fixed TimeField not handling empty values
  • Loading branch information
areski committed Jan 11, 2016
commit a76c3ed051f7d8e26db82450a20cdb9f4a683116
2 changes: 2 additions & 0 deletions rest_framework/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,8 @@ def to_representation(self, value):
)

if output_format.lower() == ISO_8601:
if (isinstance(value, str)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it works ok on python 2.* with unicode values? Seems similar to #3819

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update str to six.string_types ? (as per #3819 indeed)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will then update both DateField & TimeField to use six.string_types

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@areski The DateTime was out of this PR scope and now conflict with master. Could you merge it please ?

value = datetime.datetime.strptime(value, '%H:%M:%S').time()
return value.isoformat()
return value.strftime(output_format)

Expand Down