Fix celery worker initialization by setting up Django before Celery and fixing import name

This commit is contained in:
2026-05-05 13:09:54 +02:00
parent ce5aac0e89
commit 3eb81b343c
3 changed files with 14 additions and 5 deletions
+2 -2
View File
@@ -1,2 +1,2 @@
from .celery import app as celery_app
__all__ = ('celery_app',)
from .celery import app as celery
__all__ = ('celery',)
+4 -3
View File
@@ -1,10 +1,11 @@
from celery import Celery
import os
import django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proyecto.settings')
django.setup()
app = Celery('proyecto')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proyecto.settings')
app.config_from_object('django.conf:settings', namespace="CELERY")
app.user_options = {}
app.autodiscover_tasks()