[Fixed]-Django – How to run a function EVERYDAY?

27👍

As others have said, Celery can schedule tasks to execute at a specific time.

from celery.schedules import crontab
from celery.task import periodic_task

@periodic_task(run_every=crontab(hour=7, minute=30, day_of_week="mon"))
def every_monday_morning():
    print("This is run every Monday morning at 7:30")

Install via pip install django-celery

👤Josh

3👍

You can either write a custom management command and schedule its execution using cron, or you can use celery.

👤samu

1👍

👤grigno

Leave a comment