Skip to content
Advertisement

About values(‘created_at__day’) and values(‘created_at__week’)

I wrote this code to sum up the daily and weekly counts with multiple data registered. What do the 2,3,18,22,27 in created_atday and 7,8,9,13 in created_atweek represent? Also, is there any way to make it easier to understand, such as 2021/3/5 for day and 2021/3/6- for week? I would appreciate it if you could tell me more about this.

Data.objects.values('created_at__day').annotate(Sum('count'))
Data.objects.values('created_at__week').annotate(Sum('count'))

in the case of created_at__day

"data": [
  {
      "created_at__day": 2,
      "count__sum": 1004
  },
  {
      "created_at__day": 3,
      "count__sum": 491
  },
  {
      "created_at__day": 18,
      "count__sum": 1221
  },
  {
      "created_at__day": 22,
      "count__sum": 1201
  },
  {
      "created_at__day": 27,
      "count__sum": 999
  }
],

in the case of created_at__week

"report": [
  {
      "created_at__week": 7,
      "time__sum": 1221
  },
  {
      "created_at__week": 8,
      "time__sum": 1201
  },
  {
      "created_at__week": 9,
      "time__sum": 1663
  },
  {
      "created_at__week": 13,
      "time__sum": 999
  }
],

Advertisement

Answer

day is the integer value between 1 and 31 (including 31) which represent the day of the month

week is the integer value between 1 and 52 (including 52) which represent the week number

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement