mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Fixed #8193: all dynamic imports in Django are now done correctly. I know this because Brett Cannon borrowed the time machine and brought Python 2.7's 'importlib back for inclusion in Django. Thanks for the patch-from-the-future, Brett!
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10088 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -3,6 +3,7 @@ from django.conf import settings
|
||||
from django.core import signals
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.utils.functional import curry
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
__all__ = ('backend', 'connection', 'DatabaseError', 'IntegrityError')
|
||||
|
||||
@@ -13,12 +14,12 @@ def load_backend(backend_name):
|
||||
try:
|
||||
# Most of the time, the database backend will be one of the official
|
||||
# backends that ships with Django, so look there first.
|
||||
return __import__('django.db.backends.%s.base' % backend_name, {}, {}, [''])
|
||||
return import_module('.base', 'django.db.backends.%s' % settings.DATABASE_ENGINE)
|
||||
except ImportError, e:
|
||||
# If the import failed, we might be looking for a database backend
|
||||
# distributed external to Django. So we'll try that next.
|
||||
try:
|
||||
return __import__('%s.base' % backend_name, {}, {}, [''])
|
||||
return import_module('.base', backend_name)
|
||||
except ImportError, e_user:
|
||||
# The database backend wasn't found. Display a helpful error message
|
||||
# listing all possible (built-in) database backends.
|
||||
|
||||
Reference in New Issue
Block a user