Skip to content
Snippets Groups Projects
Commit 94f66037 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Merge branch 'bugfix/use-django-autodiscover' into 'master'

Use autodiscover code of Django for checks and model extensions

See merge request AlekSIS/official/AlekSIS!293
parents 1075db32 5463661c
No related branches found
No related tags found
1 merge request!293Use autodiscover code of Django for checks and model extensions
Pipeline #2675 failed
......@@ -2,6 +2,7 @@ from typing import Any, List, Optional, Tuple
import django.apps
from django.http import HttpRequest
from django.utils.module_loading import autodiscover_modules
from dynamic_preferences.registries import preference_models
......@@ -36,6 +37,9 @@ class CoreConfig(AppConfig):
def ready(self):
super().ready()
# Autodiscover various modules defined by AlekSIS
autodiscover_modules("form_extensions", "model_extensions", "checks")
sitepreferencemodel = self.get_model("SitePreferenceModel")
personpreferencemodel = self.get_model("PersonPreferenceModel")
grouppreferencemodel = self.get_model("GroupPreferenceModel")
......
from importlib import import_module
from typing import Any, List, Optional, Sequence, Tuple
import django.apps
......@@ -19,15 +18,6 @@ class AppConfig(django.apps.AppConfig):
def ready(self):
super().ready()
# Run model extension code
try:
import_module(
".".join(self.__class__.__module__.split(".")[:-1] + ["model_extensions"])
)
except ImportError:
# ImportErrors are non-fatal because model extensions are optional.
pass
# Register default listeners
pre_migrate.connect(self.pre_migrate, sender=self)
post_migrate.connect(self.post_migrate, sender=self)
......@@ -38,13 +28,6 @@ class AppConfig(django.apps.AppConfig):
# Getting an app ready means it should look at its config once
self.preference_updated(self)
# Register system checks of this app
try:
import_module(".".join(self.__class__.__module__.split(".")[:-1] + ["checks"]))
except ImportError:
# ImportErrors are non-fatal because checks are optional.
pass
@classmethod
def get_name(cls):
"""Get name of application package."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment