1👍
You can enumerate over the date
s, and ensure that it has for that date
an Availability
with closed=False
:
from datetime import date, timedelta
rooms = Room.objects.all()
start_date = date(2022, 7, 21) # first day
for dd in range(7): # number of days
dt = start_date + timedelta(days=dd)
rooms = rooms.filter(availability__date=dt, availability__closed=False)
The rooms
will after the for
loop have a QuerySet
with all Room
s that have for all date
s in that range Availability
objects with closed=False
.
Source:stackexchange.com