mirror of
https://github.com/thecyberlearn/modern-django-starter.git
synced 2026-08-18 16:52:55 +00:00
- Fix production.py settings to properly read environment variables with defaults - Add debug_settings management command to troubleshoot environment variable issues - Add debugging output to entrypoint.sh to see what settings are loaded - This will help identify why ALLOWED_HOSTS and CSRF_TRUSTED_ORIGINS may not be working
65 lines
1.8 KiB
Python
65 lines
1.8 KiB
Python
"""
|
|
Production settings for Django project.
|
|
"""
|
|
from .base import *
|
|
|
|
DEBUG = config('DEBUG', default=False, cast=bool)
|
|
|
|
# Override ALLOWED_HOSTS with production default if not set
|
|
ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='localhost,127.0.0.1', cast=lambda v: [s.strip() for s in v.split(',')])
|
|
|
|
# CSRF trusted origins for production (inherits from base.py but can be overridden)
|
|
CSRF_TRUSTED_ORIGINS = config('CSRF_TRUSTED_ORIGINS', default='', cast=lambda v: [s.strip() for s in v.split(',') if s.strip()])
|
|
|
|
SECURE_BROWSER_XSS_FILTER = True
|
|
SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
|
|
SECURE_HSTS_SECONDS = 31536000
|
|
SECURE_REDIRECT_EXEMPT = []
|
|
SECURE_SSL_REDIRECT = config('SECURE_SSL_REDIRECT', default=False, cast=bool)
|
|
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
|
USE_TZ = True
|
|
|
|
SESSION_COOKIE_SECURE = True
|
|
CSRF_COOKIE_SECURE = True
|
|
SECURE_HSTS_PRELOAD = True
|
|
|
|
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
|
|
|
LOGGING = {
|
|
'version': 1,
|
|
'disable_existing_loggers': False,
|
|
'formatters': {
|
|
'verbose': {
|
|
'format': '{levelname} {asctime} {module} {process:d} {thread:d} {message}',
|
|
'style': '{',
|
|
},
|
|
'simple': {
|
|
'format': '{levelname} {message}',
|
|
'style': '{',
|
|
},
|
|
},
|
|
'handlers': {
|
|
'console': {
|
|
'level': 'INFO',
|
|
'class': 'logging.StreamHandler',
|
|
'formatter': 'verbose',
|
|
},
|
|
},
|
|
'root': {
|
|
'handlers': ['console'],
|
|
'level': 'INFO',
|
|
},
|
|
'loggers': {
|
|
'django': {
|
|
'handlers': ['console'],
|
|
'level': 'INFO',
|
|
'propagate': False,
|
|
},
|
|
'django.request': {
|
|
'handlers': ['console'],
|
|
'level': 'ERROR',
|
|
'propagate': False,
|
|
},
|
|
},
|
|
} |