Ticket #12693: django_router_load_check.patch

File django_router_load_check.patch, 1.1 KB (added by dhageman, 6 years ago)
  • django/db/utils.py

    diff -ruN django_development_version/django/db/utils.py django/django/db/utils.py
    old new  
    9292        self.routers = []
    9393        for r in routers:
    9494            if isinstance(r, basestring):
    95                 module_name, klass_name = r.rsplit('.', 1)
    96                 module = import_module(module_name)
    97                 router = getattr(module, klass_name)()
     95                try:
     96                    module_name, klass_name = r.rsplit('.', 1)
     97                    module = import_module(module_name)
     98                    router = getattr(module, klass_name)()
     99                except ImportError, e:
     100                    raise ImproperlyConfigured('Error importing database router %s: "%s"' % (klass_name, e))
     101                except AttributeError:
     102                    raise ImproperlyConfigured('Module "%s" does not define a "%s" database router' % (module, klass_name))
    98103            else:
    99104                router = r
    100105            self.routers.append(router)
Back to Top