From 8f86f295ab29095a1185bcc6e70e974c7067a95c Mon Sep 17 00:00:00 2001 From: allen-munsch Date: Mon, 17 Oct 2022 11:08:45 -0500 Subject: [PATCH] Refs #32915 -- easier to understand traceback from _gcd_import --- django/apps/config.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/django/apps/config.py b/django/apps/config.py index 28e50e5225..e1a927bcf8 100644 --- a/django/apps/config.py +++ b/django/apps/config.py @@ -189,8 +189,12 @@ class AppConfig: msg += " Choices are: %s." % ", ".join(candidates) raise ImportError(msg) else: - # Re-trigger the module import exception. - import_module(entry) + try: + # Re-trigger the module import exception. + import_module(entry) + except ModuleNotFoundError: + raise ImportError( + f"The following module was not found, install the dependency or remove it from INSTALLED_APPS: {entry}") # Check for obvious errors. (This check prevents duck typing, but # it could be removed if it became a problem in practice.)