vintasoftware / django-react-boilerplate

Django 5, React, Bootstrap 5 with Python 3 and Webpack project boilerplate
MIT License
1.97k stars 479 forks source link

ImportError: cannot import name 'celery_app' #498

Closed matthieuchabert closed 3 years ago

matthieuchabert commented 4 years ago

Description

When I wanted to run a celery task, I got an error:

from config import celery_app

@celery_app.task(name="task_name")
def my_task():
    return
ImportError: cannot import name 'celery_app' from 'config' (/Users/matthieuchabert/Documents/workspace/stockpro/code/transfer/backend/config/__init__.py)

Expected behavior According to the Celery documentation, we need to add the code below to the file {{project_name}}/__init__.py

from __future__ import absolute_import, unicode_literals

# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app

__all__ = ('celery_app',)

I added it, and now it's working properly.

vanessa commented 4 years ago

Hello @matthieuchabert, thanks for reporting the issue.

Just letting you know we'll look into it and get back as soon as we find out.