【发布时间】:2011-07-11 14:23:17
【问题描述】:
我正在学习这个教程
http://celeryq.org/docs/django-celery/getting-started/first-steps-with-django.html
我用芹菜开始
python manage.py celeryd
然后我在myapp文件夹中创建了tasks.py
from celery.decorators import task
@task()
def add(x, y):
return x + y
然后我把这些放在settings.py中
import djcelery
djcelery.setup_loader()
CELERY_RESULT_BACKEND = "database"
CELERY_RESULT_DBURI = "mysql://user1:password@localhost/ajfdfa_rabbitmq"
BROKER_HOST = "localhost"
BROKER_PORT = 5672
BROKER_USER = "guest"
BROKER_PASSWORD = "guest"
BROKER_VHOST = "/"
然后我用
启动了python shellpython manage.py shell
然后我输入
从 myapp 导入任务
一切顺利
但是当我输入函数名时会出错
add.delay(4, 4)
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'add' is not defined
我错过了什么
【问题讨论】:
标签: django celery django-celery