Skip to content

Closes #76: Check for required settings on init #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions netbox_branching/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured

from netbox.plugins import PluginConfig
from netbox.registry import registry

Expand All @@ -23,6 +26,17 @@ class AppConfig(PluginConfig):
def ready(self):
super().ready()
from . import constants, events, search, signal_receivers
from .utilities import DynamicSchemaDict

# Validate required settings
if type(settings.DATABASES) is not DynamicSchemaDict:
raise ImproperlyConfigured(
"netbox_branching: DATABASES must be a DynamicSchemaDict instance."
)
if 'netbox_branching.database.BranchAwareRouter' not in settings.DATABASE_ROUTERS:
raise ImproperlyConfigured(
"netbox_branching: DATABASE_ROUTERS must contain 'netbox_branching.database.BranchAwareRouter'."
)

# Record all object types which support branching in the NetBox registry
if 'branching' not in registry['model_features']:
Expand Down