我有包含“caller_name”和“call_datetime”字段的模型。
我能够获得特定月份每天发生的电话数量:
while start_date <= end_date:
calls = CDR.objects.filter(start_time__year=str(start_date.year), start_time__month=str(start_date.month),
start_time__day=str(start_date.day))
print "Number of calls:", len(calls)
start_date = start_date + datetime.timedelta(days=1)
同样,我试图在特定日期每小时获得电话数量。
for i in range(24):
calls = CDR.objects.filter(start_time__year=str(start_date.year), start_time__month=str(start_date.month),start_time__day=str(start_date.day), start_time__hour=str(i))
发现“start_time__hour”没有实现,但是以他们的任何方式来实现这一点?