【发布时间】:2023-01-17 14:42:31
【问题描述】:
我创建了计算总时间的函数。
def emp_attendance(request):
attendance_list_ad = Attendance.objects.all()
total = None
for item in attendance_list_ad:
if item.total_time is not None:
if total is None:
total = item.total_time
else:
total += item.total_time
return render(request, 'employee/emp_attendance.html'{'attendance_list_ad': attendance_list_ad, 'total':
total})
打印时:
出勤日期 = 2023-01-09 总时间 = 1:00:00
所以我的问题是在首页这个函数正在计算数据库中所有条目的总时间。但我想按月计算总时间,因为我们有 01 月的出勤日期。然后将计算总时间
【问题讨论】: