I have the following setup with a fresh installed celery and django 1.4:
settings.py:
import djcelery
djcelery.setup_loader()
BROKER_HOST = \'localhost
I'm pretty sure you have to import the "Celery app instance" and declare a task like this:
from project_name.celery import app
@app.task
def video_process_task(video_id):
pass
note that there's a celery.py file in the project_dir/project_name folder, which declares the celery instance, like this:
from __future__ import absolute_import
import os
from celery import Celery
from django.conf import settings
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project_name.settings')
app = Celery('project_name')
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
as instructed in the official documentation.
also, you must register the task, in one of these three ways:
bind=True
to the decorator like: @app.task(bind=True)
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
, each Django application's folder can contain a tasks.py file, and the tasks declared inside it will be automatically registerednote that changes to the tasks REQUIRE A CELERY RESTART to take effect