Things changed too much in Django, so I can't use 3.1. I need some help.
I read about make a task in django, and read Periodic Tasks document. But I don't know how make periodic tasks in django. I think this becuase of my low level English..
In the older version of Celery, I imported djcelery&crontab and set CELERYBEAT_SCHEDULE in settings.py, and excuted by manage.py.
But it seems that I cannot execute celery deamon by that way anymore. Than where I should put CELERYBEAT_SCHEDULE? In django example in docs, they set os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings')
in proj/proj/celery.py. (1) So setting celerybeat in settings.py(like before) is ok?
(2) If you can, a tiny example of making periodic task in django will very helpful. When I was reading tutorials, the most confusing part was File Path. If you don't want to provide a whole example, I will really appreciate if you explain about where I should make tasks, set beat, and executed deamon.
Thanks for reading.
I assume you've already read the django section from the docs, but have you seen this example project?
It doesn't use the scheduler but if you add this to
settings.py
:Now for the commands, forget about
manage.py
, just typecelery
directly:-B
enables celery beat as always.-A
specifies the name of the celery app. Note this line in the celery.py of the example project:app = Celery('proj')
'django-celery' is not required, install it ONLY if you need to manage the schedule from the admin, or if you want to store task results in the DB through django's ORM:
You can use django-celery application: https://pypi.python.org/pypi/django-celery
Installation:
To enable django-celery for your project you need to add djcelery to INSTALLED_APPS:
then add the following lines to your settings.py:
USAGE
On linux you can run worker with celery-beat like this:
Also you will like to monitor tasks in django admin. To enable monitoring fiture you'll need to run celerycam:
To make periodic task you can use celery.decorators.periodic_task.
Or use