Skip to content

Commit 58cdeb0

Browse files
committed
refactor
1 parent 0484032 commit 58cdeb0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

django_mongodb/utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ def parse(uri, **kwargs):
3636
# If the fqdn is present, this is a SRV URI and the host is the fqdn.
3737
host = f"mongodb+srv://{uri['fqdn']}"
3838
else:
39-
if len(uri("nodelist")) == 1:
40-
host, port = uri("nodelist")[0].split(":")
41-
elif len(uri("nodelist")) > 1:
42-
host = ",".join(uri["nodelist"])
39+
nodelist = uri.get("nodelist")
40+
if len(nodelist) == 1:
41+
host, port = nodelist[0].split(":")
42+
elif len(nodelist) > 1:
43+
host = ",".join([f"{host}:{port}" for host, port in nodelist])
4344

4445
settings_dict = {
4546
"ENGINE": "django_mongodb",

0 commit comments

Comments
 (0)