以下は、userdataというテーブルのタイムスタンプ列にあるタイムスタンプです。私の質問は、月名i.2が必要なので出力を得る方法ですdjangoクエリで時刻を計算する
my_month = 2 (or whatever you need)
userdata.months.filter(timestamp__month=my_month).aggregate(sum('timestamp__time')
などの2010-03月に
userdata.months.filter().order_by('-timestamp')
'2011-03-07 16:03:01'
'2011-03-07 16:07:04'
'2011-03-06 11:03:01'
'2011-03-08 16:03:01'
'2011-03-04 09:03:01'
'2011-05-16 16:03:01'
'2011-05-18 16:03:01'
'2011-07-16 12:03:01'
'2011-07-17 12:03:01'
'2011-07-17 15:03:01'
合計使用時間はどういう意味ですか?開始日と終了日はありますか?それがあなたの質問なら、私はほぼ同じ時間前に尋ねました... https://docs.djangoproject.com/en/dev/ref/models/querysets/#monthでフィルタリングしてからhttp://stackoverflow.com/質問/ 6669875/how-to-aggregate-computed-field-with-django-orm-without-raw-sql to Duration – christophe31