1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Refs #32915 -- easier to understand traceback from _gcd_import

This commit is contained in:
allen-munsch 2022-10-17 11:08:45 -05:00
parent 5d13cc540e
commit 8f86f295ab
No known key found for this signature in database
GPG Key ID: 0C977048B8BDD447

View File

@ -189,8 +189,12 @@ class AppConfig:
msg += " Choices are: %s." % ", ".join(candidates) msg += " Choices are: %s." % ", ".join(candidates)
raise ImportError(msg) raise ImportError(msg)
else: else:
# Re-trigger the module import exception. try:
import_module(entry) # 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 # Check for obvious errors. (This check prevents duck typing, but
# it could be removed if it became a problem in practice.) # it could be removed if it became a problem in practice.)