mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 02:31:08 -05:00
Refactor environment variable configurations for consistency; ensure proper type casting for DEBUG and ALLOWED_HOSTS settings.
This commit is contained in:
@@ -7,6 +7,7 @@ from datetime import timedelta
|
|||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import List
|
||||||
from decouple import config
|
from decouple import config
|
||||||
|
|
||||||
# Suppress django-allauth deprecation warnings for dj_rest_auth compatibility
|
# Suppress django-allauth deprecation warnings for dj_rest_auth compatibility
|
||||||
@@ -19,14 +20,14 @@ warnings.filterwarnings(
|
|||||||
|
|
||||||
# Initialize environment variables with better defaults
|
# Initialize environment variables with better defaults
|
||||||
|
|
||||||
DEBUG = config("DEBUG", default=True)
|
DEBUG = config("DEBUG", default=True, cast=bool)
|
||||||
SECRET_KEY = config("SECRET_KEY")
|
SECRET_KEY = config("SECRET_KEY")
|
||||||
ALLOWED_HOSTS = config("ALLOWED_HOSTS", default="localhost,127.0.0.1", cast=lambda v: [s.strip() for s in v.split(',') if s.strip()])
|
ALLOWED_HOSTS = config("ALLOWED_HOSTS", default="localhost,127.0.0.1", cast=lambda v: [s.strip() for s in str(v).split(',') if s.strip()])
|
||||||
DATABASE_URL = config("DATABASE_URL")
|
DATABASE_URL = config("DATABASE_URL")
|
||||||
CACHE_URL = config("CACHE_URL", default="locmem://")
|
CACHE_URL = config("CACHE_URL", default="locmem://")
|
||||||
EMAIL_URL = config("EMAIL_URL", default="console://")
|
EMAIL_URL = config("EMAIL_URL", default="console://")
|
||||||
REDIS_URL = config("REDIS_URL", default="redis://127.0.0.1:6379/1")
|
REDIS_URL = config("REDIS_URL", default="redis://127.0.0.1:6379/1")
|
||||||
CORS_ALLOWED_ORIGINS = config("CORS_ALLOWED_ORIGINS", default="", cast=lambda v: [s.strip() for s in v.split(',') if s.strip()])
|
CORS_ALLOWED_ORIGINS = config("CORS_ALLOWED_ORIGINS", default="", cast=lambda v: [s.strip() for s in str(v).split(',') if s.strip()])
|
||||||
API_RATE_LIMIT_PER_MINUTE = config("API_RATE_LIMIT_PER_MINUTE", default=60)
|
API_RATE_LIMIT_PER_MINUTE = config("API_RATE_LIMIT_PER_MINUTE", default=60)
|
||||||
API_RATE_LIMIT_PER_HOUR = config("API_RATE_LIMIT_PER_HOUR", default=1000)
|
API_RATE_LIMIT_PER_HOUR = config("API_RATE_LIMIT_PER_HOUR", default=1000)
|
||||||
CACHE_MIDDLEWARE_SECONDS = config("CACHE_MIDDLEWARE_SECONDS", default=300)
|
CACHE_MIDDLEWARE_SECONDS = config("CACHE_MIDDLEWARE_SECONDS", default=300)
|
||||||
@@ -55,7 +56,7 @@ SECRET_KEY = config("SECRET_KEY")
|
|||||||
|
|
||||||
# CSRF trusted origins
|
# CSRF trusted origins
|
||||||
CSRF_TRUSTED_ORIGINS = config(
|
CSRF_TRUSTED_ORIGINS = config(
|
||||||
"CSRF_TRUSTED_ORIGINS", default="", cast=lambda v: [s.strip() for s in v.split(',') if s.strip()]
|
"CSRF_TRUSTED_ORIGINS", default="", cast=lambda v: [s.strip() for s in str(v).split(',') if s.strip()]
|
||||||
)
|
)
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|||||||
Reference in New Issue
Block a user