Fixed #32197 -- Improved error message when loading a database backend fails.
This commit is contained in:
parent
464a4c0c59
commit
4cce1d13cf
|
@ -120,8 +120,10 @@ def load_backend(backend_name):
|
||||||
if backend_name not in ['django.db.backends.%s' % b for b in builtin_backends]:
|
if backend_name not in ['django.db.backends.%s' % b for b in builtin_backends]:
|
||||||
backend_reprs = map(repr, sorted(builtin_backends))
|
backend_reprs = map(repr, sorted(builtin_backends))
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
"%r isn't an available database backend.\n"
|
"%r isn't an available database backend or couldn't be "
|
||||||
"Try using 'django.db.backends.XXX', where XXX is one of:\n"
|
"imported. Check the above exception. To use one of the "
|
||||||
|
"built-in backends, use 'django.db.backends.XXX', where XXX "
|
||||||
|
"is one of:\n"
|
||||||
" %s" % (backend_name, ", ".join(backend_reprs))
|
" %s" % (backend_name, ", ".join(backend_reprs))
|
||||||
) from e_user
|
) from e_user
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -57,8 +57,9 @@ class LoadBackendTests(SimpleTestCase):
|
||||||
|
|
||||||
def test_load_backend_invalid_name(self):
|
def test_load_backend_invalid_name(self):
|
||||||
msg = (
|
msg = (
|
||||||
"'foo' isn't an available database backend.\n"
|
"'foo' isn't an available database backend or couldn't be "
|
||||||
"Try using 'django.db.backends.XXX', where XXX is one of:\n"
|
"imported. Check the above exception. To use one of the built-in "
|
||||||
|
"backends, use 'django.db.backends.XXX', where XXX is one of:\n"
|
||||||
" 'mysql', 'oracle', 'postgresql', 'sqlite3'"
|
" 'mysql', 'oracle', 'postgresql', 'sqlite3'"
|
||||||
)
|
)
|
||||||
with self.assertRaisesMessage(ImproperlyConfigured, msg) as cm:
|
with self.assertRaisesMessage(ImproperlyConfigured, msg) as cm:
|
||||||
|
|
Loading…
Reference in New Issue