Browse Source

Fixes #1786: Correct loading of reports from a custom file path

Jeremy Stretch 7 years ago
parent
commit
5f7e21faa0
1 changed files with 3 additions and 3 deletions
  1. 3 3
      netbox/extras/reports.py

+ 3 - 3
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
     # Iterate through all modules within the reports path. These are the user-created files in which reports are
     # defined.
     # 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)]
         report_list = [cls() for _, cls in inspect.getmembers(module, is_report)]
         module_list.append((module_name, report_list))
         module_list.append((module_name, report_list))
 
 
@@ -104,7 +104,7 @@ class Report(object):
 
 
     @property
     @property
     def module(self):
     def module(self):
-        return self.__module__.rsplit('.', 1)[1]
+        return self.__module__
 
 
     @property
     @property
     def name(self):
     def name(self):