Merge branch 'master' of github.com:tomchristie/django-rest-framework

This commit is contained in:
Tom Christie 2015-09-03 11:24:07 +01:00
commit e9e88cbc60
3 changed files with 3 additions and 2 deletions

View File

@ -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:

View File

@ -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]')

View File

@ -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].'],