Changes between Version 1 and Version 2 of Ticket #24570
- Timestamp:
- Apr 2, 2015, 1:15:04 PM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #24570 – Description
v1 v2 6 6 truncate_date = connection.ops.date_trunc_sql('day', 'created_at') 7 7 8 qs = MyModel.objects.filter(user_id=1).annotate(max_date=models.Max('created_at')).extra({'created_at': truncate_date}).values('product_id','created_at','max_date') 8 qs = MyModel.objects.filter( 9 user_id=1 10 ).annotate( 11 max_date=models.Max('created_at') 12 ).extra( 13 {'created_at': truncate_date} 14 ).values( 15 'product_id', 'created_at', 'max_date' 16 ) 9 17 qs.query.group_by = ['product_id', truncate_date] 10 18 qs.order_by('-max_date')[:10] 19 11 20 }}} 12 21