mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 16:26:09 -06:00
Closes #10659: Import signals.py from Plugin
Uses the importlib.import_module function from Python to import the signals module. This registers the receiver functions to receive signals from django.
This commit is contained in:
parent
aaf829898b
commit
656bd3b530
@ -2,6 +2,8 @@ import collections
|
||||
import inspect
|
||||
from packaging import version
|
||||
|
||||
from importlib import import_module
|
||||
|
||||
from django.apps import AppConfig
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.template.loader import get_template
|
||||
@ -60,9 +62,13 @@ class PluginConfig(AppConfig):
|
||||
menu_items = 'navigation.menu_items'
|
||||
template_extensions = 'template_content.template_extensions'
|
||||
user_preferences = 'preferences.preferences'
|
||||
signals = 'signals'
|
||||
|
||||
def ready(self):
|
||||
plugin_name = self.name.rsplit('.', 1)[-1]
|
||||
|
||||
# import signals module (if existing)
|
||||
import_module(f"{self.__module__}.{self.signals}")
|
||||
|
||||
# Register template content (if defined)
|
||||
template_extensions = import_object(f"{self.__module__}.{self.template_extensions}")
|
||||
|
Loading…
Reference in New Issue
Block a user