0

How can I make the total time sum of each user being that annotate and aggregate have no support for Timefild

Models:

class Pireps(models.Model):
    ...
    flight_time = models.TimeField(auto_now=False, auto_now_add=False, null=True)

Views:

def flight(request):
    ...
    flight_time =  Pireps.objects.annotate(total_time =(Sum('flight_time')).order_by('total_time)
id date create flight time
1 22/10/22 01:10:00
1 22/10/22 01:50:00
1 22/10/22 00:40:00
2 22/10/22 00:50:00
2 22/10/22 00:50:00
3 22/10/22 01:20:00

output of the result wanted like this

id flight time
1 03:00:00
2 01:40:00
3 00:40:00

0 Answers0