'Django notification
How to display notification before two days from start date and display notfication on end date using 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')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
