根据时间间隔聚合字段

时间:2015-07-20 20:35:54

标签: python django models

我有一个这样的模型:

class MyModel(Model):
    pub_date = DateTimeField(auto_now_add=True)
    hours = IntergerField()

    def get_weekly_hours(self)
        # Find a week-ago interval based on the pub_date
        # Then based on the interval found above, aggregate the...
        # Sum the `hours` altogether
        pass

如何获取时间间隔,然后根据该值求和?

2 个答案:

答案 0 :(得分:3)

 var searchHash = $text.val();
 searchHash = searchHash.replace(/\s/g, '');

答案 1 :(得分:0)

请查看下一个链接:

  1. timedelta
  2. range
  3. aggregation