"""
WSGI config for django_project project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/
"""

import os
import sys
from pathlib import Path

# Add the project directory to Python path
BASE_DIR = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(BASE_DIR))

# Set the default Django settings module for the 'wsgi' application.
# For production server, use production settings unless explicitly overridden
if os.environ.get('DJANGO_SETTINGS_MODULE'):
    # Respect explicitly set settings
    pass
elif os.environ.get('REPLIT_DEPLOYMENT'):
    # Replit deployment
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_project.settings.production')
elif os.environ.get('REPLIT_DOMAINS'):
    # Replit development
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_project.settings.development')
else:
    # Production server (default)
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_project.settings.production')

from django.core.wsgi import get_wsgi_application

application = get_wsgi_application()