Closed bignose-debian closed 3 years ago
This change implements the correct behaviour on mine:
--- old/sitetree/utils.py
+++ new/sitetree/utils.py
@@ -186,8 +186,8 @@
from django.conf import settings as django_settings
submodules = []
- for app in django_settings.INSTALLED_APPS:
- module = import_app_sitetree_module(app)
+ for app_config in apps.app_configs.values():
+ module = import_app_sitetree_module(app_config.name)
if module is not None:
submodules.append(module)
Thank you. I'll try to review in a week.
Your patch has been incorporated in https://github.com/idlesign/django-sitetree/commit/8430b64e20f784b44c68cc03115c4fdee18fc7b0
Considered closed. Thank you.
Your patch has been incorporated in 8430b64
Thank you!
When
sitetree.utils.import_project_sitetree_modules
iterates applications for their module name, it currently uses thesettings.INSTALLED_APPS
sequence. But the entries in that sequence are not necessarily module names; each one might be the name of a class. Importing names from a class as though it is a package, will fail.From the documentation for
INSTALLED_APPS
:If any
INSTALLED_APPS
entry does not name a module,sitetree.utils.import_app_sitetree_module
receives that name and attempts to use it as a module namespace. When the name is not the name of a module, this fails withModuleNotFoundError
.Instead, the iteration in
sitetree.utils.import_project_sitetree_modules
should use the functionality provided by thedjango.apps.apps
registry, and directly use theAppConfig.name
for its qualified module name.