I have the following model in my Django application :
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']
I want to print out the values of PeopleCount where if the difference between the time of enlisting of two objects is less than 1 seconds I can aggregate their values. For example:
- Let's say I get PeopleCountObjA -> at 11:30:21 (where people_count_entry was 4)
- And then I get another value PeopleCountObjB -> at 11:30:22(where people_Count_entry was 2)
- I should get answer as Group Count should be 6
- The time 11:30:21 and 11:30:22 refers to recorded_time field from the model.
I tried using the aggregate query but unable to put in filter for delta difference of one second.
Hope I am clear with the question. TIA