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
e9e88cbc
Commit
e9e88cbc
authored
Sep 03, 2015
by
Tom Christie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:tomchristie/django-rest-framework
parents
f9d1a34f
ec007a7e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
2 deletions
+3
-2
docs/api-guide/relations.md
+1
-1
rest_framework/fields.py
+1
-1
tests/test_fields.py
+1
-0
No files found.
docs/api-guide/relations.md
View file @
e9e88cbc
...
@@ -501,7 +501,7 @@ For example, given the following model for a tag, which has a generic relationsh
...
@@ -501,7 +501,7 @@ For example, given the following model for a tag, which has a generic relationsh
tagged_object = GenericForeignKey('content_type', 'object_id')
tagged_object = GenericForeignKey('content_type', 'object_id')
def __unicode__(self):
def __unicode__(self):
return self.tag
return self.tag
_name
And the following two models, which may be have associated tags:
And the following two models, which may be have associated tags:
...
...
rest_framework/fields.py
View file @
e9e88cbc
...
@@ -1189,7 +1189,7 @@ class DurationField(Field):
...
@@ -1189,7 +1189,7 @@ class DurationField(Field):
def
to_internal_value
(
self
,
value
):
def
to_internal_value
(
self
,
value
):
if
isinstance
(
value
,
datetime
.
timedelta
):
if
isinstance
(
value
,
datetime
.
timedelta
):
return
value
return
value
parsed
=
parse_duration
(
value
)
parsed
=
parse_duration
(
six
.
text_type
(
value
)
)
if
parsed
is
not
None
:
if
parsed
is
not
None
:
return
parsed
return
parsed
self
.
fail
(
'invalid'
,
format
=
'[DD] [HH:[MM:]]ss[.uuuuuu]'
)
self
.
fail
(
'invalid'
,
format
=
'[DD] [HH:[MM:]]ss[.uuuuuu]'
)
...
...
tests/test_fields.py
View file @
e9e88cbc
...
@@ -1069,6 +1069,7 @@ class TestDurationField(FieldValues):
...
@@ -1069,6 +1069,7 @@ class TestDurationField(FieldValues):
'3 08:32:01.000123'
:
datetime
.
timedelta
(
days
=
3
,
hours
=
8
,
minutes
=
32
,
seconds
=
1
,
microseconds
=
123
),
'3 08:32:01.000123'
:
datetime
.
timedelta
(
days
=
3
,
hours
=
8
,
minutes
=
32
,
seconds
=
1
,
microseconds
=
123
),
'08:01'
:
datetime
.
timedelta
(
minutes
=
8
,
seconds
=
1
),
'08:01'
:
datetime
.
timedelta
(
minutes
=
8
,
seconds
=
1
),
datetime
.
timedelta
(
days
=
3
,
hours
=
8
,
minutes
=
32
,
seconds
=
1
,
microseconds
=
123
):
datetime
.
timedelta
(
days
=
3
,
hours
=
8
,
minutes
=
32
,
seconds
=
1
,
microseconds
=
123
),
datetime
.
timedelta
(
days
=
3
,
hours
=
8
,
minutes
=
32
,
seconds
=
1
,
microseconds
=
123
):
datetime
.
timedelta
(
days
=
3
,
hours
=
8
,
minutes
=
32
,
seconds
=
1
,
microseconds
=
123
),
3600
:
datetime
.
timedelta
(
hours
=
1
),
}
}
invalid_inputs
=
{
invalid_inputs
=
{
'abc'
:
[
'Duration has wrong format. Use one of these formats instead: [DD] [HH:[MM:]]ss[.uuuuuu].'
],
'abc'
:
[
'Duration has wrong format. Use one of these formats instead: [DD] [HH:[MM:]]ss[.uuuuuu].'
],
...
...
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