"""
passenger_wsgi.py — cPanel + Phusion Passenger entry point for Django.

DEPLOYMENT STEPS:
  1. Upload your project to cPanel (e.g. /home/USERNAME/std_pro1/)
  2. Place this file in your APPLICATION ROOT (the folder cPanel points to).
     Usually: /home/USERNAME/std_pro1/passenger_wsgi.py
  3. Create a Python App in cPanel → "Setup Python App"
     - Python version: 3.9+ (3.11 recommended)
     - Application root: std_pro1
     - Application URL: / (or your subdomain)
     - Application startup file: passenger_wsgi.py
  4. Activate the virtualenv and install deps:
       source /home/USERNAME/virtualenv/std_pro1/3.11/bin/activate
       pip install -r requirements.txt
       pip install mysqlclient
  5. Run migrations:
       python manage.py migrate
       python manage.py collectstatic --noinput
  6. Restart the app from cPanel → "Setup Python App" → Restart
"""

import os
import sys

# ============================================================
# 1. PATHS — Adjust 'USERNAME' to your cPanel username
# ============================================================
# Your project directory (where manage.py lives)
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))

# Add project directory to Python path
if PROJECT_DIR not in sys.path:
    sys.path.insert(0, PROJECT_DIR)

# Also add parent directory if needed
PARENT_DIR = os.path.dirname(PROJECT_DIR)
if PARENT_DIR not in sys.path:
    sys.path.insert(0, PARENT_DIR)

# ============================================================
# 2. DJANGO SETTINGS MODULE
# ============================================================
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'std_pro.settings')

# ============================================================
# 3. WSGI APPLICATION
# ============================================================
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
