hi i have below code working fine:
if getattr(hotel_main, "X", 1):
hotels1 = hotels.filter(Q(X=True))
for hotel in hotels1:
if models.CalendarDay.objects.filter(hotel=hotel, date=date).count() == 0:
similar_venues.append(hotel)
I reused above code again and again to check different conditions like Q(Y=True),Q(Y=True),Q(Z=True)
if i can filter a list based on the condition i can get rid of repeating code… i want something like this: similar_venues.filter(Q(X=True)) Any help please…
If i understood correctly what you asked:
and so on for all the X, Y, Z