Answer the question
In order to leave comments, you need to log in
Why doesn't celery send an email at the specified time?
I sent mail an hour before the event (model in django), checked the date check in the shell, but celery does not send mail or print to the console. There is a premonition that something has not been completed, since it has not worked with the planned actions yet. but no ideas. I didn’t include shedule.py anywhere, maybe this is the reason for
tasks.py:
@shared_task
def event_send_mail():
events = Event.objects.filter(event_date=datetime.now() + timedelta(minutes=60))
for event in events:
print("Событие")
send_mail("Напоминание о событии", str(event.title) + "начинаеся через час",
"[email protected]", [event.user.email, ])
CELERYBEAT_SCHEDULE = {
'send_mail': {
'task': 'send_mail',
'schedule': timedelta(minutes=1),
},
}
Answer the question
In order to leave comments, you need to log in
celery is quite bulky for such simple tasks. I would advise you to use python rq. To complete your task, you will need to set up a Django environment inside the task to load the required models. Then just pick up cron. This is the simplest and helps to get rid of complicated celery
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question