Config celery app immediately after the app being created, otherwise it is too late.
@@ -11,6 +11,11 @@ if not settings.configured:
app = Celery('{{cookiecutter.project_slug}}')
+# Using a string here means the worker will not have to
+# pickle the object when using Windows.
+# - namespace='CELERY' means all celery-related configuration keys
+# should have a `CELERY_` prefix.
+app.config_from_object('django.conf:settings', namespace='CELERY')
class CeleryAppConfig(AppConfig):
@@ -18,11 +23,6 @@ class CeleryAppConfig(AppConfig):
verbose_name = 'Celery Config'
def ready(self):
- # Using a string here means the worker will not have to
- # pickle the object when using Windows.
- # - namespace='CELERY' means all celery-related configuration keys
- # should have a `CELERY_` prefix.
- app.config_from_object('django.conf:settings', namespace='CELERY')
installed_apps = [app_config.name for app_config in apps.get_app_configs()]
app.autodiscover_tasks(lambda: installed_apps, force=True)
