From 267a14264b12d9d1cb6c572932b4c18ccd51df83 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 13 Mar 2023 08:52:38 -0400 Subject: [PATCH] Fixes #11927: Correct loading of plugin resources with custom paths --- docs/release-notes/version-3.4.md | 1 + netbox/extras/plugins/__init__.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/version-3.4.md b/docs/release-notes/version-3.4.md index 1a66a674c..2bd0ee40b 100644 --- a/docs/release-notes/version-3.4.md +++ b/docs/release-notes/version-3.4.md @@ -22,6 +22,7 @@ * [#11819](https://github.com/netbox-community/netbox/issues/11819) - Fix filtering of cable terminations by object type * [#11850](https://github.com/netbox-community/netbox/issues/11850) - Fix loading of CSV files containing a byte order mark * [#11903](https://github.com/netbox-community/netbox/issues/11903) - Fix escaping of return URL values for action buttons in tables +* [#11927](https://github.com/netbox-community/netbox/issues/11927) - Correct loading of plugin resources with custom paths --- diff --git a/netbox/extras/plugins/__init__.py b/netbox/extras/plugins/__init__.py index b56113ca1..6f29855f5 100644 --- a/netbox/extras/plugins/__init__.py +++ b/netbox/extras/plugins/__init__.py @@ -78,8 +78,8 @@ class PluginConfig(AppConfig): def _load_resource(self, name): # Import from the configured path, if defined. - if getattr(self, name): - return import_string(f"{self.__module__}.{self.name}") + if path := getattr(self, name, None): + return import_string(f"{self.__module__}.{path}") # Fall back to the resource's default path. Return None if the module has not been provided. default_path = f'{self.__module__}.{DEFAULT_RESOURCE_PATHS[name]}'