I have a Django model that defines TimeSlot. Each TimeSlot can contain a certain number of users ( TimeSlot.spots). Each TimeSlot also have a certain number of users who are already in it (many, many fields TimeSlot.participants.
When I move on to a template that displays the available TimeSlots to the user, I comment with the help TimeSlot.objects.annotate(Count('participants'))that gives the number of users that are currently stored in TimeSlot as participants__count.
However, I really want the number of spots remaining, capacity ( TimeSlot.spots) minus the number that is currently being held ( participants__count). How can I annotate another field with this new number, so I can pass it to the template?
source
share