我跟着導遊http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html,但我無法找到如何導入芹菜應用在應用級tasks.py,它這樣使用:如何在Django應用程序級任務中導入Celery應用程序?
@app.task()
def do_my_task():
我跟着導遊http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html,但我無法找到如何導入芹菜應用在應用級tasks.py,它這樣使用:如何在Django應用程序級任務中導入Celery應用程序?
@app.task()
def do_my_task():
的@shared_task裝飾可以讓你創建任務,而無需任何具體的應用程序實例,這是一個比task
更簡單的API使用。
from celery import shared_task
@shared_task
def add(x, y):
return x + y
怎麼樣:從芹菜導入任務? – user1518217
更新了我的答案 – arjun27
你的意思是頂級項目芹菜配置到應用級? – Robert
我的意思是應用程序級別: app/ tasks.py – user1518217