我的Django应用程序中具有以下模型:
class PeopleCount(models.Model):
"""
A webapp model classs to store People Count Details.
"""
timestamp = models.DateTimeField(auto_now=True)
people_count_entry = models.IntegerField(blank=True, null=True)
people_count_exit = models.IntegerField(blank=True, null=True)
store = models.ForeignKey(Store, blank=True, null=True)
profile = models.ForeignKey(Profile)
camera = models.ForeignKey(Camera)
recorded_time = models.DateTimeField(null=True, blank=True)
def __str__(self):
return "People Count {}".format(self.timestamp)
class Meta:
verbose_name = "People Count"
verbose_name_plural = "People Count"
ordering = ['-recorded_time']
我想打印出PeopleCount的值,如果两个对象的入伍时间之间的差小于1秒,则可以汇总它们的值。例如:
我尝试使用聚合查询,但是无法放入过滤器以获得一秒钟的差异。
希望我对这个问题很清楚。 TIA