Reputation: 321
Here the time format is not same in terminal and postman,I do not know why this is so, is there any way to change the time value?
x = VideoDetails.objects.filter(video__coursemodulevideos__module_id).aggregate(Sum('duration'))
print('x', x)
print('x',x['duration__sum'])
result = { "ho":x['duration__sum'] }
In terminal the output is
x {'duration__sum': datetime.timedelta(seconds=130)}
x 0:02:10
but in postman
"hour": { "duration__sum": "P0DT00H02M10S" } Give me a solution to solve this problem.
Upvotes: 1
Views: 64
Reputation: 476557
You can pass the str(…)
of the timedelta
to the result, so:
result = { 'hour': str(x['duration__sum']) }
Upvotes: 1