Files
thrillwiki_django_no_react/backend/config/django/local.py
pac7 ebe65e7c9d Update development settings to exclude Redis health checks
Temporarily remove `health_check.contrib.redis` from `INSTALLED_APPS` in `backend/config/django/local.py` for development environments.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 9bc9dd7a-5328-4cb7-91de-b3cb33a0c48c
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
2025-09-22 00:15:16 +00:00

191 lines
5.6 KiB
Python

"""
Local development settings for thrillwiki project.
"""
from ..settings import database
import logging
from .base import *
# Import database configuration
DATABASES = database.DATABASES
# Development-specific settings
DEBUG = True
# For local development, allow all hosts
ALLOWED_HOSTS = ["*"]
# CSRF trusted origins for local development
CSRF_TRUSTED_ORIGINS = [
"http://localhost:8000",
"http://127.0.0.1:8000",
"https://beta.thrillwiki.com",
]
GDAL_LIBRARY_PATH = "/nix/store/c5y314zvvrbr9lx4wh06ibl1b5c07x92-gdal-3.11.0/lib/libgdal.so"
GEOS_LIBRARY_PATH = "/nix/store/r5sgxqxrwfvms97v4v239qbivwsmdfjf-geos-3.13.1/lib/libgeos_c.so"
# Local cache configuration
LOC_MEM_CACHE_BACKEND = "django.core.cache.backends.locmem.LocMemCache"
CACHES = {
"default": {
"BACKEND": LOC_MEM_CACHE_BACKEND,
"LOCATION": "unique-snowflake",
"TIMEOUT": 300, # 5 minutes
"OPTIONS": {"MAX_ENTRIES": 1000},
},
"sessions": {
"BACKEND": LOC_MEM_CACHE_BACKEND,
"LOCATION": "sessions-cache",
"TIMEOUT": 86400, # 24 hours (same as SESSION_COOKIE_AGE)
"OPTIONS": {"MAX_ENTRIES": 5000},
},
"api": {
"BACKEND": LOC_MEM_CACHE_BACKEND,
"LOCATION": "api-cache",
"TIMEOUT": 300, # 5 minutes
"OPTIONS": {"MAX_ENTRIES": 2000},
},
}
# Development-friendly cache settings
CACHE_MIDDLEWARE_SECONDS = 1 # Very short cache for development
CACHE_MIDDLEWARE_KEY_PREFIX = "thrillwiki_dev"
# Development email backend - Use ForwardEmail for actual email sending
# EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" # Console for debugging
EMAIL_BACKEND = "django_forwardemail.backends.ForwardEmailBackend" # Actual email sending
# Security settings for development
SECURE_SSL_REDIRECT = False
SESSION_COOKIE_SECURE = False
CSRF_COOKIE_SECURE = False
# Development monitoring tools
DEVELOPMENT_APPS = [
# "silk", # Disabled for performance
"nplusone.ext.django",
"django_extensions",
"widget_tweaks",
]
# Add development apps if available
for app in DEVELOPMENT_APPS:
if app not in INSTALLED_APPS:
INSTALLED_APPS.append(app)
# Remove Redis health check for development (Redis not available)
DEVELOPMENT_EXCLUDED_APPS = [
"health_check.contrib.redis", # Remove Redis health check - causes connection errors
]
# Remove Redis-dependent apps for development
for app in DEVELOPMENT_EXCLUDED_APPS:
if app in INSTALLED_APPS:
INSTALLED_APPS.remove(app)
# Development middleware
DEVELOPMENT_MIDDLEWARE = [
# "silk.middleware.SilkyMiddleware", # Disabled for performance
"nplusone.ext.django.NPlusOneMiddleware",
"core.middleware.performance_middleware.PerformanceMiddleware",
"core.middleware.performance_middleware.QueryCountMiddleware",
"core.middleware.nextjs.APIResponseMiddleware", # Add this
"core.middleware.request_logging.RequestLoggingMiddleware", # Request logging
]
# Add development middleware
for middleware in DEVELOPMENT_MIDDLEWARE:
if middleware not in MIDDLEWARE:
MIDDLEWARE.insert(1, middleware) # Insert after security middleware
# Debug toolbar configuration
INTERNAL_IPS = ["127.0.0.1", "::1"]
# Silk configuration disabled for performance
# NPlusOne configuration
NPLUSONE_LOGGER = logging.getLogger("nplusone")
NPLUSONE_LOG_LEVEL = logging.WARN
# Enhanced development logging
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"verbose": {
"format": "{levelname} {asctime} {module} {process:d} {thread:d} {message}",
"style": "{",
},
"json": {
"()": "pythonjsonlogger.jsonlogger.JsonFormatter",
"format": (
"%(levelname)s %(asctime)s %(module)s %(process)d "
"%(thread)d %(message)s"
),
},
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"formatter": "verbose",
},
"file": {
"class": "logging.handlers.RotatingFileHandler",
"filename": BASE_DIR / "logs" / "thrillwiki.log",
"maxBytes": 1024 * 1024 * 10, # 10MB
"backupCount": 5,
"formatter": "json",
},
"performance": {
"class": "logging.handlers.RotatingFileHandler",
"filename": BASE_DIR / "logs" / "performance.log",
"maxBytes": 1024 * 1024 * 10, # 10MB
"backupCount": 5,
"formatter": "json",
},
},
"root": {
"level": "INFO",
"handlers": ["console"],
},
"loggers": {
"django": {
"handlers": ["file"],
"level": "WARNING", # Reduced from INFO
"propagate": False,
},
"django.db.backends": {
"handlers": ["console"],
"level": "WARNING", # Reduced from DEBUG
"propagate": False,
},
"thrillwiki": {
"handlers": ["console", "file"],
"level": "INFO", # Reduced from DEBUG
"propagate": False,
},
"performance": {
"handlers": ["performance"],
"level": "WARNING", # Reduced from INFO
"propagate": False,
},
"query_optimization": {
"handlers": ["console", "file"],
"level": "WARNING",
"propagate": False,
},
"nplusone": {
"handlers": ["console"],
"level": "ERROR", # Reduced from WARNING
"propagate": False,
},
"request_logging": {
"handlers": ["console"],
"level": "INFO",
"propagate": False,
},
},
}