I have Clocking table in database. I wanted to count the users’ time spent per day.
For example 2024-03-21
, user 1 spend 6.8 hours
, the next day he spends n number of hours and so on (['6.8', 'n', ... 'n']
)
user | date | timein | timeout |
---|---|---|---|
1 | 2024-03-21 | 10:42 AM | 12:00 PM |
1 | 2024-03-21 | 01:10 PM | 06:00 PM |
1 | 2024-03-22 | 01:00 PM | 05:47 PM |
… | … | … | … |
This is my models.py
class Clocking(models.Model):
user = models.ForeignKey('User', models.DO_NOTHING)
timein = models.CharField(max_length=15, blank=True, null=True)
timeout = models.CharField(max_length=15, blank=True, null=True)
date = models.DateField(null=False)
I wanted to get the list of hours spent per day, which would be really useful for me in plotting charts.
New contributor
zheni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3