3👍
✅
You can filter with:
Tour.objects.filter(
dates__departure_date__gt='2022-04-12',
dates__return_date__lt='2022-05-01'
).distinct()
This will make a JOIN
on the table of the TourDatesInfo
model, and filter on the departure_date
and return_date
. If there is thus such TourDatesInfo
, it will return the Tour
data. The .distinct()
call [Django-doc] is used to prevent returning the same Tour
for as many times as there are matching TourDatesInfo
s.
Source:stackexchange.com