Skip to content

Commit 1161948

Browse files
committed
Add parse
1 parent 36c5718 commit 1161948

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

django_mongodb/utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from django.core.exceptions import ImproperlyConfigured
77
from django.db.backends.utils import logger
88
from django.utils.version import get_version_tuple
9+
from pymongo.uri_parser import parse_uri
910

1011

1112
def check_django_compatability():
@@ -25,6 +26,16 @@ def check_django_compatability():
2526
)
2627

2728

29+
def parse(uri):
30+
uri = parse_uri(uri)
31+
return {
32+
"ENGINE": "django_mongodb",
33+
"HOST": uri["fqdn"] or None,
34+
"USERNAME": uri.get("username"),
35+
"PASSWORD": uri.get("password"),
36+
}
37+
38+
2839
def set_wrapped_methods(cls):
2940
"""Initialize the wrapped methods on cls."""
3041
if hasattr(cls, "logging_wrapper"):

0 commit comments

Comments
 (0)