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
  • Last modified: 2024/10/05 06:15
  • by 127.0.0.1