I have a button that should appear 1 day before the model object's start_date. In my view I have a functions that tells me if the object's start_date or end_date is now.
def has_engagement(self):
from rental.models import Inquiry
inquiries = Inquiry.objects.filter(inquiryequipment__equipment=self).filter(start_date__lte= timezone.now()).\
filter(end_date__gte=timezone.now()).filter(status="CO")
if not inquiries:
return False
# no current confirmed engagement
else:
return True
# there is a current confirmed engagement
instead of this, i need to check if today is a day before the start or end dates. Any ideas? Thanks
start_date-timedelta(1)
? it will give previous day.timezone.now()
?timezone.now()
django's wrapper to datetime which enables timezone functionalities according to configuration of timezone specified insettings.py
by default it will followUTC
timezone