Skip to content

Commit fe9c607

Browse files
atul-bhouraskarPhotonios
authored andcommitted
Iterate through all databases to check if at least one of them is configured to use psqlextra.backend
1 parent e69ee68 commit fe9c607

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

psqlextra/manager/manager.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,22 @@ def __init__(self, *args, **kwargs):
1818

1919
super().__init__(*args, **kwargs)
2020

21-
# make sure our back-end is set and refuse to proceed
21+
# make sure our back-end is set in at least one db and refuse to proceed
2222
# if it's not set
23-
db_backend = settings.DATABASES["default"]["ENGINE"]
24-
if "psqlextra" not in db_backend:
23+
def has_pqlextra_backend():
24+
for db_alias, db_settings in settings.DATABASES.items():
25+
db_backend = db_settings['ENGINE']
26+
if "psqlextra" in db_backend:
27+
return True
28+
return False
29+
30+
if not has_pqlextra_backend():
2531
raise ImproperlyConfigured(
2632
(
27-
"'%s' is not the 'psqlextra.backend'. "
33+
"Could not locate the 'psqlextra.backend'. "
2834
"django-postgres-extra cannot function without "
2935
"the 'psqlextra.backend'. Set DATABASES.ENGINE."
3036
)
31-
% db_backend
3237
)
3338

3439
def truncate(

0 commit comments

Comments
 (0)