I have a django view:
order_amount = Item.objects.filter(order_id = order_id).values(‘order_id’).annotate(order_value=Sum(‘total’)).order_by(‘order_id’)
which generates the following QuerySet:
<QuerySet [{‘order_id’: 46, ‘order_value’: Decimal (‘140137.20’)} ]>
How do i get only the order_value from the QuerySet?
I tried the following:’
for order in order_amount:
order_value = order.order_value
print(order_value)
but an error was returned:
‘dict’ object has no attribute ‘order_value’
Guidance please.