From 5f7e21faa01329ebc60afdf977a7bf7184416e70 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 31 Jul 2018 13:48:07 -0400 Subject: [PATCH] Fixes #1786: Correct loading of reports from a custom file path --- netbox/extras/reports.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netbox/extras/reports.py b/netbox/extras/reports.py index b84363763..9b45f47aa 100644 --- a/netbox/extras/reports.py +++ b/netbox/extras/reports.py @@ -46,8 +46,8 @@ def get_reports(): # Iterate through all modules within the reports path. These are the user-created files in which reports are # defined. - for importer, module_name, is_pkg in pkgutil.walk_packages([settings.REPORTS_ROOT]): - module = importlib.import_module('reports.{}'.format(module_name)) + for importer, module_name, _ in pkgutil.iter_modules([settings.REPORTS_ROOT]): + module = importer.find_module(module_name).load_module(module_name) report_list = [cls() for _, cls in inspect.getmembers(module, is_report)] module_list.append((module_name, report_list)) @@ -104,7 +104,7 @@ class Report(object): @property def module(self): - return self.__module__.rsplit('.', 1)[1] + return self.__module__ @property def name(self):