芹菜在due_date上发送电子邮件

发布于 2025-02-13 02:24:09 字数 237 浏览 1 评论 0原文

日期有所不同。

根据模型中使用芹菜中的截止日期将电子邮件发送给用户,Due_date与创建任务 models.py

class Task(BaseModel):
    name = models.CharField(max_length=255)
    due_date = models.DateField(blank=True, null=True)

Sending email to the users based on the due date in model using the celery, the due_date is something different from date when a task is created

Models.py

class Task(BaseModel):
    name = models.CharField(max_length=255)
    due_date = models.DateField(blank=True, null=True)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那小子欠揍 2025-02-20 02:24:09
@shared_task
def send_email():
    today = datetime.now()
    tasks = Task.objects.filter(due_date__date=today)
    for task in tasks:
        # Send email task

每天运行此任务。芹菜节拍使运行周期性任务变得容易 - https://docs.celeryq.dev/en/stable/userguide/periodic-tasks.html#beat-custom-schedulers

@shared_task
def send_email():
    today = datetime.now()
    tasks = Task.objects.filter(due_date__date=today)
    for task in tasks:
        # Send email task

Run this task daily. Celery Beat makes running periodic tasks easy - https://docs.celeryq.dev/en/stable/userguide/periodic-tasks.html#beat-custom-schedulers

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文