You have to provide a configuration for the Celery instance. Create a new file next to the settings.py file of myshop and name it celery.py. This file will contain the Celery configuration for your project. Add the following code to it:
import osfrom celery import Celery# set the default Django settings module for the 'celery' program.os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myshop.settings')app = Celery('myshop')app.config_from_object('django.conf:settings', namespace='CELERY')app.autodiscover_tasks()
In this code, we do the following:
- We set the DJANGO_SETTINGS_MODULE variable for the Celery command-line program.
- We create an instance of the application with app = Celery('myshop').
- We load any custom ...