diff options
| author | William Schwartz <wkschwartz@gmail.com> | 2021-01-04 00:16:13 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-04 07:16:13 +0100 |
| commit | 0ea1866f6e41c35c504fdd0f1232f96793414f96 (patch) | |
| tree | 22aa257f68da370c33f361873d4ab9230ee5317c /django/db/utils.py | |
| parent | 060e6bdd1f96f46d43fa34636284c20525a96f20 (diff) | |
Simplified django.db.utils.load_backend().
Previously load_backend() performed search by computing the (sole)
entry of django.db.backends.__path__ manually from
django.db.utils.__file__. Now django.db.backends.__path__ is used
directly.
Diffstat (limited to 'django/db/utils.py')
| -rw-r--r-- | django/db/utils.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/django/db/utils.py b/django/db/utils.py index c7e6297f7a..f79c3586f8 100644 --- a/django/db/utils.py +++ b/django/db/utils.py @@ -1,6 +1,5 @@ import pkgutil from importlib import import_module -from pathlib import Path from django.conf import settings from django.core.exceptions import ImproperlyConfigured @@ -113,9 +112,9 @@ def load_backend(backend_name): except ImportError as e_user: # The database backend wasn't found. Display a helpful error message # listing all built-in database backends. - backend_dir = str(Path(__file__).parent / 'backends') + import django.db.backends builtin_backends = [ - name for _, name, ispkg in pkgutil.iter_modules([backend_dir]) + name for _, name, ispkg in pkgutil.iter_modules(django.db.backends.__path__) if ispkg and name not in {'base', 'dummy', 'postgresql_psycopg2'} ] if backend_name not in ['django.db.backends.%s' % b for b in builtin_backends]: |
