from .settings import *
from dotenv import load_dotenv
import os

load_dotenv(BASE_DIR / "{{ project_name }}/.env.prod")

DEBUG = False
ALLOWED_HOSTS = ["{{ domain|default:'*' }}"]
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY")

STATIC_ROOT = BASE_DIR / "staticfiles"

# WhiteNoise config
MIDDLEWARE.insert(1, 'whitenoise.middleware.WhiteNoiseMiddleware')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
db_path = BASE_DIR / "db"
db_path.mkdir(parents=True, exist_ok=True)
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db', 'db.sqlite3'),
        "OPTIONS": {
            "init_command": (
                "PRAGMA foreign_keys=ON;"
                "PRAGMA journal_mode = WAL;"
                "PRAGMA synchronous = NORMAL;"
                "PRAGMA busy_timeout = 5000;"
                "PRAGMA temp_store = MEMORY;"
                "PRAGMA mmap_size = 134217728;"
                "PRAGMA journal_size_limit = 67108864;"
                "PRAGMA cache_size = 2000;"
            ),
            "transaction_mode": "IMMEDIATE",
        },
    }
}
