mirror of
https://github.com/django/django.git
synced 2024-12-01 15:42:04 +01:00
Fixed #12718 -- Tighten up the error handling when loading database routers. Thanks to Jeff Balogh for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12336 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
7856a759d0
commit
0cdd36fac8
@ -95,11 +95,12 @@ class ConnectionRouter(object):
|
||||
try:
|
||||
module_name, klass_name = r.rsplit('.', 1)
|
||||
module = import_module(module_name)
|
||||
router = getattr(module, klass_name)()
|
||||
except ImportError, e:
|
||||
raise ImproperlyConfigured('Error importing database router %s: "%s"' % (klass_name, e))
|
||||
try:
|
||||
router = getattr(module, klass_name)()
|
||||
except AttributeError:
|
||||
raise ImproperlyConfigured('Module "%s" does not define a "%s" database router' % (module, klass_name))
|
||||
raise ImproperlyConfigured('Module "%s" does not define a database router name "%s"' % (module, klass_name))
|
||||
else:
|
||||
router = r
|
||||
self.routers.append(router)
|
||||
|
Loading…
Reference in New Issue
Block a user