Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 获取类型错误:';模块';对象不能在芹菜任务装饰器上调用_Django_Celery - Fatal编程技术网

Django 获取类型错误:';模块';对象不能在芹菜任务装饰器上调用

Django 获取类型错误:';模块';对象不能在芹菜任务装饰器上调用,django,celery,Django,Celery,在为django尝试芹菜时,我遇到了@task decorator的问题。这是在Windows7上运行的 在我的celerytest.tasks模块中,我有以下代码 from celery import task @task def add(x,y): return x + y 在命令提示符下,我运行: python manage.py shell 正在尝试从shell导入我的模块: from celerytest.tasks import add 我得到以下错误: >&g

在为django尝试芹菜时,我遇到了@task decorator的问题。这是在Windows7上运行的

在我的celerytest.tasks模块中,我有以下代码

from celery import task

@task
def add(x,y):
    return x + y
在命令提示符下,我运行:

python manage.py shell
正在尝试从shell导入我的模块:

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
>>来自celerytest.tasks导入添加
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“d:\…\celerytest\tasks.py”,第8行,在
@任务
TypeError:“模块”对象不可调用

我用谷歌搜索了很长一段时间,但似乎我是世界上唯一一个有这个问题的人。

嗯,我正在阅读2.6.0 rc3的文档,但安装了2.5.3

当像这样使用导入时:

from celery.task import task

一切似乎都正常。

但是,通过导入,我收到了一个弃用警告。更好:
来自芹菜。任务导入任务