尝试在django芹菜中使用tasks.py时出错

时间:2017-04-13 23:41:58

标签: django celery django-celery

我尝试用芹菜和django做一些非常基本的事情。特别是在我的app.py中的应用程序:

from __future__ import absolute_import, unicode_literals
from celery import Celery
app = Celery( broker='redis://localhost:6379/0')

@app.task
def add(x, y):
    return x + y

并在此应用的views.py中:

from .tasks import *

def index(request):
    add.delay(4, 4)
    return HttpResponse("you are in index")

当我开始运行芹菜并去索引芹菜过程时会引发错误。

我跑:

celery -A tasks worker

,错误是:

[2017-04-14 00:53:12,404: ERROR/MainProcess] Received unregistered task 
of type 'rango.tasks.add'.
The message has been ignored and discarded.

Did you remember to import the module containing this task?
Or maybe you're using relative imports?'

我做错了什么?

0 个答案:

没有答案