From 425b618a3a856e04500bf281813224163a593c09 Mon Sep 17 00:00:00 2001 From: Damien Arnodo Date: Wed, 7 Jan 2026 14:55:50 +0000 Subject: [PATCH] feat: add local_settings.py for netbox-branching DynamicSchemaDict --- images/netbox/local_settings.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 images/netbox/local_settings.py diff --git a/images/netbox/local_settings.py b/images/netbox/local_settings.py new file mode 100644 index 0000000..2be7021 --- /dev/null +++ b/images/netbox/local_settings.py @@ -0,0 +1,28 @@ +# ============================================================================= +# NetBox Local Settings for netbox-branching plugin +# ============================================================================= +# This file configures DynamicSchemaDict required by netbox-branching. +# It wraps the DATABASE configuration from the parent configuration.py +# ============================================================================= + +import os +from netbox_branching.utilities import DynamicSchemaDict + +# Wrap DATABASES with DynamicSchemaDict for dynamic schema support +# This is required for netbox-branching plugin to function correctly +DATABASES = DynamicSchemaDict({ + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': os.environ.get('DB_NAME', 'netbox'), + 'USER': os.environ.get('DB_USER', 'netbox'), + 'PASSWORD': os.environ.get('DB_PASSWORD', ''), + 'HOST': os.environ.get('DB_HOST', 'localhost'), + 'PORT': os.environ.get('DB_PORT', ''), + 'CONN_MAX_AGE': int(os.environ.get('DB_CONN_MAX_AGE', 300)), + } +}) + +# Employ the custom database router for branch-aware queries +DATABASE_ROUTERS = [ + 'netbox_branching.database.BranchAwareRouter', +]