Skip to content

Commit 5a0064d

Browse files
committed
Catch Settings already configures exception
1 parent 1545f82 commit 5a0064d

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

openstates/utils/django.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ def init_django() -> None: # pragma: no cover
1515
else:
1616
DATABASES["default"]["OPTIONS"]["application_name"] = application_name
1717

18-
conf.settings.configure(
19-
conf.global_settings,
20-
SECRET_KEY="not-important",
21-
DEBUG=False,
22-
INSTALLED_APPS=(
23-
"django.contrib.contenttypes",
24-
"openstates.data",
25-
),
26-
DATABASES=DATABASES,
27-
TIME_ZONE="UTC",
28-
MIDDLEWARE_CLASSES=(),
29-
)
30-
django.setup()
18+
try:
19+
conf.settings.configure(
20+
conf.global_settings,
21+
SECRET_KEY="not-important",
22+
DEBUG=False,
23+
INSTALLED_APPS=(
24+
"django.contrib.contenttypes",
25+
"openstates.data",
26+
),
27+
DATABASES=DATABASES,
28+
TIME_ZONE="UTC",
29+
MIDDLEWARE_CLASSES=(),
30+
)
31+
django.setup()
32+
except RuntimeError as e:
33+
if "Settings already configured." not in str(e):
34+
raise RuntimeError(f"Encountered error {e}")

0 commit comments

Comments
 (0)