""" Django settings for seduttomotorsports project. """ from pathlib import Path import os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = os.environ.get("SECRET_KEY", "django-insecure-change-this-in-production") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = os.environ.get("DEBUG", "False") == "True" ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "*").split(",") # Application definition INSTALLED_APPS = [ "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "quotes", ] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "whitenoise.middleware.WhiteNoiseMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", ] ROOT_URLCONF = "seduttomachineworks_project.urls" TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [BASE_DIR / "templates"], "APP_DIRS": True, "OPTIONS": { "context_processors": [ "django.template.context_processors.debug", "django.template.context_processors.request", "django.contrib.messages.context_processors.messages", ], }, }, ] WSGI_APPLICATION = "seduttomachineworks_project.wsgi.application" # Database # https://docs.djangoproject.com/en/4.2/ref/settings/#databases # Use local/data directory in DEBUG mode, otherwise use /app/data if DEBUG: DATA_DIR = BASE_DIR / "local" / "data" DATA_DIR.mkdir(parents=True, exist_ok=True) DATABASES = { "default": { "ENGINE": "django.db.backends.sqlite3", "NAME": DATA_DIR / "db.sqlite3", } } else: DATA_DIR = Path("/app/data") DATA_DIR.mkdir(parents=True, exist_ok=True) DATABASES = { "default": { "ENGINE": "django.db.backends.sqlite3", "NAME": DATA_DIR / "db.sqlite3", } } # Internationalization # https://docs.djangoproject.com/en/4.2/topics/i18n/ LANGUAGE_CODE = "en-us" TIME_ZONE = "America/New_York" USE_I18N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.2/howto/static-files/ STATIC_URL = "static/" STATIC_ROOT = BASE_DIR / "staticfiles" STATICFILES_DIRS = [BASE_DIR / "static"] # WhiteNoise configuration for serving static files STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" MEDIA_URL = "media/" # Use local/data/uploads in DEBUG mode, otherwise use /app/data/uploads if DEBUG: DATA_DIR = BASE_DIR / "local" / "data" DATA_DIR.mkdir(parents=True, exist_ok=True) MEDIA_ROOT = DATA_DIR / "uploads" MEDIA_ROOT.mkdir(parents=True, exist_ok=True) else: DATA_DIR = Path("/app/data") DATA_DIR.mkdir(parents=True, exist_ok=True) MEDIA_ROOT = DATA_DIR / "uploads" MEDIA_ROOT.mkdir(parents=True, exist_ok=True) # Default primary key field type # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" # Allow iframe embedding (for the quoting upload box) # Note: We'll handle this per-view using @xframe_options_exempt decorator # Email configuration EMAIL_CONFIG = None try: from .email_config import get_email_config email_config = get_email_config() if email_config: EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" EMAIL_HOST = email_config["host"] EMAIL_PORT = email_config["port"] EMAIL_USE_SSL = True # Port 465 uses SSL EMAIL_HOST_USER = email_config["user"] EMAIL_HOST_PASSWORD = email_config["password"] DEFAULT_FROM_EMAIL = email_config["from_email"] SERVER_EMAIL = email_config["from_email"] EMAIL_CONFIG = email_config else: # Fallback to console backend for development EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" except Exception as e: # If email config fails, use console backend EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" # Owner email for notifications OWNER_EMAIL = os.environ.get("OWNER_EMAIL", "")