summaryrefslogtreecommitdiff
path: root/django/db/utils.py
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-12-25 13:24:39 +0000
committerJannis Leidel <jannis@leidel.info>2011-12-25 13:24:39 +0000
commitdb2b1458b1fc83c8485687634934b7c4909cde78 (patch)
treee17855d7814272e05601ed43d8948de17eaf640d /django/db/utils.py
parentff1f423d29f431e732978ac44d2ad9d5a8917d17 (diff)
downloaddjango-db2b1458b1fc83c8485687634934b7c4909cde78.tar.gz
Fixed #17047 -- Improved django.db.utils.load_backend to raise a better exception when using a unqualified database backend name. Thanks, Jonas Obrist.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17274 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/utils.py')
-rw-r--r--django/db/utils.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/django/db/utils.py b/django/db/utils.py
index 41ad6df728..3f5b86ee12 100644
--- a/django/db/utils.py
+++ b/django/db/utils.py
@@ -32,16 +32,26 @@ def load_backend(backend_name):
and not f.startswith('.')]
except EnvironmentError:
available_backends = []
- if backend_name.startswith('django.db.backends.'):
+ full_notation = backend_name.startswith('django.db.backends.')
+ if full_notation:
backend_name = backend_name[19:] # See #15621.
if backend_name not in available_backends:
- error_msg = ("%r isn't an available database backend. \n" +
- "Try using django.db.backends.XXX, where XXX is one of:\n %s\n" +
- "Error was: %s") % \
- (backend_name, ", ".join(map(repr, sorted(available_backends))), e_user)
+ backend_reprs = map(repr, sorted(available_backends))
+ error_msg = ("%r isn't an available database backend.\n"
+ "Try using django.db.backends.XXX, where XXX "
+ "is one of:\n %s\nError was: %s" %
+ (backend_name, ", ".join(backend_reprs), e_user))
+ raise ImproperlyConfigured(error_msg)
+ elif not full_notation:
+ # user tried to use the old notation for the database backend
+ error_msg = ("%r isn't an available database backend.\n"
+ "Try using django.db.backends.%s instead.\n"
+ "Error was: %s" %
+ (backend_name, backend_name, e_user))
raise ImproperlyConfigured(error_msg)
else:
- raise # If there's some other error, this must be an error in Django itself.
+ # If there's some other error, this must be an error in Django
+ raise
class ConnectionDoesNotExist(Exception):