I have following model in django
Business ID
Business Name
Business Revenue
Date
Here is the sample data:
Business ID | Business Name | Business Revenue | Date
1 B1 1000 2012-10-13
2 B2 20000 2013-10-16
1 B1 2000 2013-04-13
2 B2 24000 2014-09-02
I want to fetch all businesses having latest date.
Here is the output I want:
Business ID | Business Name | Business Revenue | Date
1 B1 2000 2013-04-13
2 B2 24000 2014-09-02
I have tried this:
model.objects.filter(date__gte = date.today()).order_by('business_id', '-date')
This is giving me group of businesses having latest business in each group at the top of it. How do I omit the rest of rows? I need some assistance