2012-06-02 10 views
5

djangoのセロリを試しています。@taskデコレータに問題がありました。シェルからの私のモジュールをインポートしようとしTypeErrorの取得:セルラーのタスクデコレータで 'Module'オブジェクトが呼び出せません

python manage.py shell 

:これは私が実行して、コマンドプロンプトから次のコード

from celery import task 

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

を持っている私のcelerytest.tasksモジュールでのWindows 7上

を実行しています:

from celerytest.tasks import add 

私は次のエラーを取得する:

>>> from celerytest.tasks import add 
Traceback (most recent call last): 
File "<console>", line 1, in <module> 
File "d:\...\celerytest\tasks.py", line 8, in <module> 
    @task 
TypeError: 'module' object is not callable 

私はこれを長年にわたってグーグルで試してみましたが、私はこの問題の世界で唯一のようです。

答えて

9

私は2.6.0 rc3のドキュメントを読んでいましたが、2.5.3をインストールしました。

http://ask.github.com/celery/django/first-steps-with-django.html

次のようにインポートを使用する場合:

from celery.task import task 

すべてが動作しているようです。

+2

このインポートでは、廃止予定の警告が表示されています。より良い: 'from celery.tasks import task'。 –

+0

変更ありがとうございます。 – vedran

関連する問題