open:django-model-count

django model count

start_date = timezone.now() - datetime.timedelta(days=day)
query_set = History.objects.filter(target=TARGET_SEARCH).filter(datetime__gte=start_date).values(
    'target_id').annotate(
    count=Count('target_id'),
    search=F('target_id')
).order_by('-count').values('count', 'search')

  • open/django-model-count.txt
  • 마지막으로 수정됨: 2020/06/18 05:45
  • 저자 127.0.0.1