4
You’ll need to add error checking but you could do something like this logic-wise:
total = 0
cart_items = CartItem.objects.filter(ticket__event=event) # assuming there are multiple cart items per event
for cart_item in cart_items:
new_total = cart_item.ticket.price * cart_item.quantity
total = total + new_total
That should give you total revenue for an event.
Source:stackexchange.com