Monday, November 30, 2015

Capture and save celery tasks information into the database in your Django project

In my experience, It's a good idea that you can store the celery tasks information into the database so you can have a better idea about what going in the background without touching the enormous logs pool. Here is how easy it is to do it:

1. In your Django project's settings.py:

CELERY_RESULT_BACKEND = 'db+mysql://mydbuser:mydbpasswd@localhost/mydb'
CELERY_TRACK_STARTED = True
CELERY_SEND_TASK_SENT_EVENT = True

2. Along side with celeryd, you need to run the celerycam app:

(venv)$ ./manage.py celerycam

3. And then in your Django admin's dashboard, go to tasks under Djcelery section and enjoy the greatness: