Only include plugin URLs when app is in INSTALLED_APPS

Skip dynamic plugin URL inclusion for plugins that are on disk but not
in Django INSTALLED_APPS to avoid RuntimeError when loading models.
Plugin installer adds apps to INSTALLED_APPS on install; this prevents
breakage when that step was missed or reverted.
This commit is contained in:
master3395
2026-02-03 19:09:46 +01:00
parent 0225f2f95a
commit df7c5ba234

View File

@@ -99,7 +99,13 @@ urlpatterns = [
]
# Dynamically include each installed plugin's URLs so /plugins/<plugin_name>/settings/ etc. work
# Only include plugins that are in INSTALLED_APPS so Django can load their models.
from django.conf import settings
_installed_apps = getattr(settings, 'INSTALLED_APPS', ())
for _plugin_name, _path_parent in _get_installed_plugin_list():
if _plugin_name not in _installed_apps:
continue
try:
# If plugin is from a source path, ensure it is on sys.path so import works
if _path_parent not in sys.path: