I am pretty new to Python, and trying to find a better way to code this. There has to be a way but just not sure how to do it.
The two queries are essentially the same, so there has to be a way to reduce. Is there a more efficient way to do this?
if set_date is not None:
if is_rejected != 'true':
query = query\
.filter(createddate__lte=set_date) \
.car_statuses(CarTow.TOWED) \
.order_by('-createddate')
else:
query = query\
.filter(createddate__lte=set_date) \
.car_statuses(CarTow.TOWED,CarTow.CONFIRMED) \
.order_by('-createddate')
return query
Sorry if this is a simple question, newbie here.