Reputation: 22489
I have this SQL
select product_id, date_booked, sum(quantity) from booking_hotelcheck where client_id=1 and status='Complete'
group by product_id, date_booked
and it returns :
and i try to convert it to django queryset:
>>> HotelCheck.objects.filter(client=1,status='Complete').values('product','date_booked','quantity').aggregate(Sum('quantity'))
{}
>>>
but it returns an empty set...
is my django queryset didn't convert my SQL? can anyone can give me an idea on how can I convert my SQL to django queryset?
thanks in advance...
Upvotes: 3
Views: 1787
Reputation: 31951
HotelCheck.objects.filter(client=1, status='Complete').values('product','date_booked').annotate(Sum('quantity'))
Upvotes: 4