Merged [5613] from mcr@sandelman.ca: include a way to dump timedeltafields so that it is possible to save data to fixtures.

- Legacy-Id: 5785
Note: SVN reference [5613] has been migrated to Git commit 32cb1d83e78d890cc286fb47131489a74dda4b21
This commit is contained in:
Henrik Levkowetz 2013-06-10 20:33:07 +00:00
parent 8330afa082
commit ec2550db84

View file

@ -54,6 +54,8 @@ class DjangoJSONEncoder(simplejson.JSONEncoder):
return o.strftime(self.TIME_FORMAT)
elif isinstance(o, decimal.Decimal):
return str(o)
elif isinstance(o, datetime.timedelta):
return o.days * 24*60*60 + o.seconds
else:
return super(DjangoJSONEncoder, self).default(o)