diff --git a/panel/src/panel/settings.py b/panel/src/panel/settings.py index 4ca359c6..90f6fe27 100644 --- a/panel/src/panel/settings.py +++ b/panel/src/panel/settings.py @@ -176,14 +176,15 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' # TODO(@fricklerhandwerk): # we may want to do this with a flat environment instead, and get all values from `os.environ.get()`. # this would make it more obvious which moving parts there are, if that environment is specified for development/staging/production in a visible place. -user_settings_file = env["USER_SETTINGS_FILE"] -spec = importlib.util.spec_from_file_location("user_settings", user_settings_file) -if spec is None or spec.loader is None: - raise RuntimeError("User settings specification failed!") -module = importlib.util.module_from_spec(spec) -spec.loader.exec_module(module) -sys.modules["user_settings"] = module -from user_settings import * # noqa: F403 # pyright: ignore [reportMissingImports] +user_settings_file = env.get("USER_SETTINGS_FILE", None) +if user_settings_file is not None: + spec = importlib.util.spec_from_file_location("user_settings", user_settings_file) + if spec is None or spec.loader is None: + raise RuntimeError("User settings specification failed!") + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + sys.modules["user_settings"] = module + from user_settings import * # noqa: F403 # pyright: ignore [reportMissingImports] # non-Django application settings