我正在关注本教程
http://celeryq.org/docs/django-celery/getting-started/first-steps-with-django.html
我开始用芹菜
python manage.py celeryd
然后我tasks.py
在myapp
文件夹中制作
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 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
我错过了什么