Celery и Redis: Ошибка: Недопустимое значение для '-A' / '--app': Невозможно загрузить приложение celery. Модуль 'project' не имеет атрибута 'celery' [закрыто]
Hello I am trying to connect connect connect asynchronous tasks via 'Celery' and message broker 'Redis'. Installed pip install celery
I created a file celery.py next to settings.py and in it I wrote the following configuration
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
app = Celery('project')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
app.autodiscover_tasks(['accounts', 'shop'])
Also, as recommended in the Celery documentation, added
from .celery import app as celery_app
all = ('celery_app',)
Created the file celery.py next to settings.py and in it I wrote the following configuration enter image description here
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
app = Celery('project')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
app.autodiscover_tasks(['accounts', 'shop'])
Also, as recommended in the Celery documentation, added
from .celery import app as celery_app
all = ('celery_app',)
C GitHab (https://github.com/microsoftarchive/redis/releases) downloaded Redis-x64-3.0.504.zip unzipped and opened the files 'redis-server.exe' and 'redis-cli.exe'
pip install redis
and wrote it in the project settings
CELERY_BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
Further in the terminal:
py manage.py runserver
And entered:
celery -A project worker -l INFO --pool=solo
But the terminal displays an error:
Usage: celery [OPTIONS] COMMAND [ARGS]
Try 'celery --help' for help.
Error: Invalid value for '-A' / '--app':
Unable to load celery application.
Module 'project' has no attribute 'celery'
Is there any experts who have encountered such a thing and how to fix the error?
Tried changing parameters in files, but the error still does not go away. I've been sitting on the problem for an hour and nothing comes to mind.