Я делаю первые шаги, чтобы добавить задачи Celery в фоновом режиме в моем приложении Django.Но я все еще получаю ошибку.
File "C:\Users\tymot\Desktop\send_sms_oferia\app_rama\app_rama\__init__.py", line 5, in <module>
from .celery import app as celery_app
File "C:\Users\tymot\Desktop\send_sms_oferia\app_rama\app_rama\celery.py", line 17, in <module>
app.autodiscover_tasks()
TypeError: autodiscover_tasks() missing 1 required positional argument: 'packages'
Откуда может возникнуть эта ошибка?Как я могу решить это?
Я пытаюсь выполнить свои действия в соответствии с этой документацией , поэтому мой файл выглядит так: celery.py (в каталоге моего проекта):
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app_rama.settings')
app = Celery('app_rama')
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings')
# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))
Мой __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',)
Любая помощь будет оценена.