How do i schedule notification for this program? i am using channels to create notification and use "crontab" for scheduling but it doesn't work.
def my_schedule_job():
vehicle_objs = Vehicle.objects.all()
for vehicle_obj in vehicle_objs:
insurance_expiry = vehicle_obj.insurance_expiry
insurance_expiry_date = insurance_expiry - timedelta(days=5)
today = date.today()
print('insurance_expiry_date',insurance_expiry_date)
print('today',today)
if insurance_expiry_date == today:
notification_obj = Notification(user_id=vehicle_obj.user_id,notification="Your insurance for {} will expire on {}".format(vehicle_obj.vehicle,insurance_expiry) ,is_seen=False)
notification_obj.save()
elif insurance_expiry_date <= today:
notification_obj = Notification(user_id=vehicle_obj.user_id,notification=vehicle_obj.vehicle + " insurance is going to expire on " + str(insurance_expiry),is_seen=False)
notification_obj.save()