我按照指南http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html进行操作,但我无法在app-level tasks.py中找到如何导入celery应用程序,其中使用方式如下:
jQuery("#grid").jqGrid({
url: "serverAction",
datatype: "json",
mtype: "POST",
pager: true,
pgbuttons: false,
pginput: false,
pgtext: false,
postData: {
currentCompanyCode: function () {
return jQuery("#availCompanyCodes").val();
}
},
colModel:[
//{name: "id", label: "key", hidden: true, key: true},
{name: "priority", label: "prio"},
....
{name: "act", label: "", align: "left", template: "actions"}
],
navOptions: { edit: false, del: false, search: false, add: false },
inlineNavOptions: { add: true, edit: true },
actionsNavOptions: { delbutton: true, editbutton: true },
inlineEditing: {
keys: true,
extraparam: {
currentCompanyCode: function () {
return jQuery("#availCompanyCodes").val();
}
},
aftersavefunc: function () {
var $grid = jQuery(this);
setTimeout(function () {
$grid.trigger("reloadGrid");
});
}
}
}) .jqGrid("navGrid")
.jqGrid("inlineNav");
答案 0 :(得分:0)
@shared_task装饰器允许您创建任务而无需任何具体的应用程序实例,这是一个比task
更简单的API。
from celery import shared_task
@shared_task
def add(x, y):
return x + y