Commits

Luke Plant committed c8a2131

Efficiency tweak

  • Participants
  • Parent commits fafd9be
  • Branches bookings

Comments (0)

Files changed (1)

File cciw/officers/views.py

     # Booked or cancelled places are included.
     payable = payable.filter(bookings__state=BOOKING_BOOKED) | payable.filter(bookings__state=BOOKING_CANCELLED)
     # annotation works over the bookings filtered above
-    outstanding = payable.annotate(total_amount_due=Sum('bookings__amount_due')).exclude(total_amount_due=F('total_received'))
+    outstanding = payable.only('id','total_received').annotate(total_amount_due=Sum('bookings__amount_due')).exclude(total_amount_due=F('total_received'))
 
     total_amount_due_dict = dict((o.id, o.total_amount_due) for o in outstanding)