1๐
โ
If I understood you correctly, this may do it
TrafficData.objects\
.filter(business_id__in=competitors)\
.annotate(max_date=Max('date'))\
.order_by('-max_date')\
.values('business_id', 'visits', 'max_date')
๐คC14L
Source:stackexchange.com