瀏覽代碼

Merge pull request #1217 from erikr/better-settings-errors2

Fixed #20443 -- Import errors in settings cause confusing error messages
Claude Paroz 12 年之前
父節點
當前提交
1a4b435218
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      django/conf/__init__.py

+ 4 - 1
django/conf/__init__.py

@@ -127,7 +127,10 @@ class Settings(BaseSettings):
         try:
             mod = importlib.import_module(self.SETTINGS_MODULE)
         except ImportError as e:
-            raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
+            raise ImportError(
+                "Could not import settings '%s' (Is it on sys.path? Is there an import error in the settings file?): %s"
+                % (self.SETTINGS_MODULE, e)
+            )
 
         # Settings that should be converted into tuples if they're mistakenly entered
         # as strings.