File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -28,23 +28,29 @@ def check_django_compatability():
28
28
29
29
def parse (uri ):
30
30
uri = parse_uri (uri )
31
-
32
- # If fqdn is None then this is not a SRV URI, so we need to extract the port
33
- # from the first node in the nodelist.
31
+ name = None
34
32
port = None
33
+
35
34
if uri ["fqdn" ] is None :
35
+ # If fqdn is None then this is not a SRV URI, so we need to extract the
36
+ # port from the first node in the nodelist.
36
37
if "nodelist" in uri and isinstance (uri ["nodelist" ], list ) and len (uri ["nodelist" ]) > 0 :
37
38
first_node = uri ["nodelist" ][0 ]
38
39
if isinstance (first_node , tuple ) and len (first_node ) > 1 and isinstance (first_node [1 ], int ):
39
40
port = first_node [1 ]
41
+ else :
42
+ # The fqdn is not none so we need to add the mongodb+srv:// prefix to the host.
43
+ host = f"mongodb+srv://{ uri ['fqdn' ]} "
40
44
41
- return {
45
+ url = {
42
46
"ENGINE" : "django_mongodb" ,
43
- "HOST" : uri ["fqdn" ] or None ,
47
+ "NAME" : uri ["database" ],
48
+ "HOST" : host ,
44
49
"PORT" : port ,
45
50
"USERNAME" : uri .get ("username" ),
46
51
"PASSWORD" : uri .get ("password" ),
47
52
}
53
+ return (url )
48
54
49
55
50
56
def set_wrapped_methods (cls ):
You can’t perform that action at this time.
0 commit comments