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...
HotelCheck.objects.filter(client=1, status='Complete').values('product','date_booked').annotate(Sum('quantity'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With