Как отобразить уведомление до двух дней от начальной даты и отобразить уведомление в конечную дату с помощью django?
from django.shortcuts import render
from app.models import maintenance
def notification(request): time_obj = maintenance.time_obj before_two_days = time_obj - datetime.timedelta(days=2)
today = datetime.date.today()
print('before_two_days',before_two_days)
print('today',today)
if before_two_days > today:
msg = maintenance(start_date=maintenance.start_date,msg = f"Your site will be under construction on {before_two_days}",is_seen=False)
msg.save()
else:
msg = maintenance(end_date=maintenance.end_date,msg = f"Your site will be reopen on {maintenance.end_date}",is_seen=False)
msg.save()
return render(request,'site.html')