Getting the amount of guests in bookings made django

后端 未结 2 2012
误落风尘
误落风尘 2021-01-23 02:29

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

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-23 02:44

    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
    

提交回复
热议问题