""" Django settings for extremum project. Generated by 'django-admin startproject' using Django 5.0.6. For more information on this file, see https://docs.djangoproject.com/en/5.0/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/5.0/ref/settings/ """ import os from pathlib import Path # import dj_database_url # 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/5.0/howto/deployment/checklist/ SECRET_KEY = os.environ.get('SECRET_KEY', "changeme") # DEBUG setting DEBUG = bool(int(os.environ.get('DEBUG', 0))) ALLOWED_HOSTS = ["127.0.0.1"] ALLOWED_HOSTS_ENV = os.environ.get('ALLOWED_HOSTS') if ALLOWED_HOSTS_ENV : ALLOWED_HOSTS.extend(ALLOWED_HOSTS_ENV.split(',')) DEBUG_PROPAGATE_EXCEPTIONS = True SECURE_HSTS_SECONDS = 31536000 # One year SECURE_HSTS_INCLUDE_SUBDOMAINS = True SECURE_HSTS_PRELOAD = True SECURE_SSL_REDIRECT = False SESSION_COOKIE_SECURE = False CSRF_COOKIE_SECURE = False # Application definition INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "base.apps.BaseConfig", ] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "whitenoise.middleware.WhiteNoiseMiddleware", # Add this line "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", ] ROOT_URLCONF = "extremum.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.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", ], }, }, ] # WSGI_APPLICATION = "extremum.wsgi.application" # Database # https://docs.djangoproject.com/en/5.0/ref/settings/#databases DATABASES = { "default": { "ENGINE": "django.db.backends.sqlite3", "NAME": BASE_DIR / "db.sqlite3", } } # if 'DATABASE_URL' in os.environ: # DATABASES['default'] = dj_database_url.config( # conn_max_age=500, # conn_health_checks=True, # ) # Password validation # https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", }, { "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", }, { "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", }, { "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", }, ] # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/5.0/howto/static-files/ # Static files (CSS, JavaScript, Images) STATIC_URL = "/static/" # Directory for collecting all static files (for production) STATIC_ROOT = BASE_DIR / "staticfiles" # Directories containing your static files (development) STATICFILES_DIRS = [ BASE_DIR / "base/static", ] # Media files (user-uploaded content) MEDIA_URL = "/media/" MEDIA_ROOT = BASE_DIR / "vol/web/media" # Whitenoise settings (optional, for improved static file serving) STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"