如何在django芹菜中为周期性任务提供动态时间段

时间:2016-11-23 08:02:17

标签: django celery django-celery celerybeat periodic-task

我有一项任务是在特定场合的一小时之前向我的用户发送提醒邮件。如何设置定期任务的时间?

`code`
@periodic_task( ? )
def auto_email():
    subject = "Exam"
    date_time = datetime.now()
    body = ""
    to = []
    after_hour_time = date_time +  timedelta(minutes=60)
    student_qs = Student.objects.filter(date_time = after_hour_time)
    for obj in student_qs :
       to.append(obj.email)     
    send_mail(subject, body, settings.EMAIL_HOST_USER,to)

由于

0 个答案:

没有答案