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:
Selfmade-RuLeZ 2022-10-15 23:49:46 +02:00 committed by GitHub
parent aaf829898b
commit 656bd3b530
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,8 @@ import collections
import inspect import inspect
from packaging import version from packaging import version
from importlib import import_module
from django.apps import AppConfig from django.apps import AppConfig
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.template.loader import get_template from django.template.loader import get_template
@ -60,9 +62,13 @@ class PluginConfig(AppConfig):
menu_items = 'navigation.menu_items' menu_items = 'navigation.menu_items'
template_extensions = 'template_content.template_extensions' template_extensions = 'template_content.template_extensions'
user_preferences = 'preferences.preferences' user_preferences = 'preferences.preferences'
signals = 'signals'
def ready(self): def ready(self):
plugin_name = self.name.rsplit('.', 1)[-1] plugin_name = self.name.rsplit('.', 1)[-1]
# import signals module (if existing)
import_module(f"{self.__module__}.{self.signals}")
# Register template content (if defined) # Register template content (if defined)
template_extensions = import_object(f"{self.__module__}.{self.template_extensions}") template_extensions = import_object(f"{self.__module__}.{self.template_extensions}")