Celery: auto discovery does not find tasks module in app

前端 未结 7 2186
说谎
说谎 2021-02-19 19:50

I have the following setup with a fresh installed celery and django 1.4:

settings.py:

import djcelery
djcelery.setup_loader()

BROKER_HOST = \'localhost         


        
7条回答
  •  忘掉有多难
    2021-02-19 20:18

    For any one who stumbles here looking for similar problem solution.

    In my case it was switching from old module bases INSTALLED_APPS setting to a new AppConfig based configuration.

    New applications should avoid default_app_config. Instead they should require the dotted path to the appropriate AppConfig subclass to be configured explicitly in INSTALLED_APPS.

    To fix this you should change the way you feed packages to celery, as stated here in the 2248 Celery issue:

    from django.apps import apps
    app.autodiscover_tasks(lambda: [n.name for n in apps.get_app_configs()]
    

    Instead of the old Celery 3 way:

    app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
    

提交回复
热议问题