1👍
for first, you can try like this:
return Timesheet.objects.annotate(total_hour=Sum('working_hour')).filter(owner=self.user, date__gte=last_year).order_by('date')
.values_list('total_hour', flat=True)
this will give you array data of total_hour
in api view from enter link description here you must edit
@api_view(['GET'])
def timesheet_total_per_month(request):
hours = ReturnHour(request.user.pk, datetime.datetime.now().isocalendar()[1])
timesheets = hours.get_month_hours()
return Response({'data':timesheets})
Source:stackexchange.com