If each a user goes into an event they can make an booking, but each event only has a certain amount of space open.
I would like to show in the event that there are 5 ou
if i correctly understand, you can try
@property
def bookings_total(self):
return self.bookings_set.filter(bookingstatus='y').count()
@property
def bookings_left(self):
return self.bookings_total - self.seats
Try:
events = Events.objects.filter(active='a').\
filter(Q(date__gte=today)|Q(date=today)).order_by('date')
events = events.filter(Q(booking__bookingstatus='n')|Q(booking__bookingstatus='p'))
events = events.annotate(num_of_seats=Count('booking'))
and now you can use, .num_of_seats
to show no of seats in an event.
In html file:
{% for event in events %}
{{event.title}}
{{even.num_of_seats}}
{% endfor %}