23 lines
662 B
Python
23 lines
662 B
Python
"""
|
|
https://docs.celeryq.dev/en/stable/django/first-steps-with-django.html
|
|
"""
|
|
import os
|
|
|
|
from celery import Celery
|
|
|
|
from django.conf import settings
|
|
|
|
# this code copied from manage.py
|
|
# set the default Django settings module for the 'celery' app.
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.settings')
|
|
|
|
# you can change the name here
|
|
app = Celery("main")
|
|
|
|
# read config from Django settings, the CELERY namespace would make celery
|
|
# config keys has `CELERY` prefix
|
|
app.config_from_object('django.conf:settings', namespace='CELERY')
|
|
|
|
# discover and load tasks.py from all registered Django apps
|
|
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
|
|
|