django model JobError(id int pk,create_time datetime [2017-07-24 00:00:14]) sql如下:
SELECT time_format,count(id) as total
from (SELECT
id,
date_format(create_time, '%Y-%m-%d %H:%i') AS time_format
FROM monitor_job_error
WHERE create_time > '2017-7-24')as tab
GROUP BY time_format
我现在想使用django orm,当selct create_time执行date_format时该怎么办。
JobError.objects.filter(create_time__gte=(datetime.now()-relativedelta(hours=15))).order_by('create_time').values('create_time').annotate(total=Count('id'))`
伙计们,请帮忙。感谢:!)