Search code examples
pythondjangocelerydjango-celerycelerybeat

What is proper way to use local settings for celerybeat in Django?


Im using django 1.8.7, django-celery 3.1.17. I want to override celery periodic tasks in local_settings, which i include at the end of basic settings file.

This code in local settings file doesnt work:

BROKER_URL = 'amqp://test:test@localhost/'
CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"
CELERYBEAT_SCHEDULE = {
    "test_task": {
        "task": "test.ptask",
        "schedule": crontab(minute="*/5"),
        "options": {'queue': 'slow_tasks'}
    }
}

Solution

  • When you call celery directly it will not obey the django settings.py. Instead call with

    manage.py celery -A test worker -l warn -Q slow_tasks --concurrency=10
    

    Please note you should add django-celery to your INSTALLED_APP.

    Also please check this page: http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#generic-initd-celerybeat-django-example