Update DATABASES syntax.

This commit is contained in:
Kelly Shutt
2025-08-04 13:10:06 -04:00
parent 477decd80a
commit 109ef8afd2

View File

@ -64,19 +64,21 @@ if '*' not in ALLOWED_HOSTS and 'localhost' not in ALLOWED_HOSTS:
# PostgreSQL database configuration. See the Django documentation for a complete list of available parameters: # PostgreSQL database configuration. See the Django documentation for a complete list of available parameters:
# https://docs.djangoproject.com/en/stable/ref/settings/#databases # https://docs.djangoproject.com/en/stable/ref/settings/#databases
DATABASE = { DATABASES = {
'NAME': environ.get('DB_NAME', 'netbox'), # Database name 'default': {
'USER': environ.get('DB_USER', ''), # PostgreSQL username 'NAME': environ.get('DB_NAME', 'netbox'), # Database name
'PASSWORD': _read_secret('db_password', environ.get('DB_PASSWORD', '')), 'USER': environ.get('DB_USER', ''), # PostgreSQL username
# PostgreSQL password 'PASSWORD': _read_secret('db_password', environ.get('DB_PASSWORD', '')),
'HOST': environ.get('DB_HOST', 'localhost'), # Database server # PostgreSQL password
'PORT': environ.get('DB_PORT', ''), # Database port (leave blank for default) 'HOST': environ.get('DB_HOST', 'localhost'), # Database server
'OPTIONS': {'sslmode': environ.get('DB_SSLMODE', 'prefer')}, 'PORT': environ.get('DB_PORT', ''), # Database port (leave blank for default)
# Database connection SSLMODE 'OPTIONS': {'sslmode': environ.get('DB_SSLMODE', 'prefer')},
'CONN_MAX_AGE': _environ_get_and_map('DB_CONN_MAX_AGE', '300', _AS_INT), # Database connection SSLMODE
# Max database connection age 'CONN_MAX_AGE': _environ_get_and_map('DB_CONN_MAX_AGE', '300', _AS_INT),
'DISABLE_SERVER_SIDE_CURSORS': _environ_get_and_map('DB_DISABLE_SERVER_SIDE_CURSORS', 'False', _AS_BOOL), # Max database connection age
# Disable the use of server-side cursors transaction pooling 'DISABLE_SERVER_SIDE_CURSORS': _environ_get_and_map('DB_DISABLE_SERVER_SIDE_CURSORS', 'False', _AS_BOOL),
# Disable the use of server-side cursors transaction pooling
}
} }
# Redis database settings. Redis is used for caching and for queuing background tasks such as webhook events. A separate # Redis database settings. Redis is used for caching and for queuing background tasks such as webhook events. A separate