from django.db.models import Count, Max
MyClass.objects.values('my_integer').annotate(count=Count('my_integer'),
    latest_date=Max('created_ts'))
How to make Django Queryset that selects records with max value within a group