set env vars necessary for celery within celery config

This commit is contained in:
Joel Mathew Thomas
2025-01-11 03:00:40 +05:30
parent 3d0630560d
commit 15b69ae37b
+11
View File
@@ -1,5 +1,16 @@
import os
import sys
from celery import Celery
# Automatically set environment variables in celery_app.py
# Set Django settings module
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
# Add the project directory to sys.path (similar to the manual PYTHONPATH)
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(project_root)
app = Celery('backend')
# Load configuration from Django settings, using the CELERY namespace.