Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. # django model count {{tag>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:15by 127.0.0.1