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():
2828
2929def parse (uri ):
3030 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
3432 port = None
33+
3534 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.
3637 if "nodelist" in uri and isinstance (uri ["nodelist" ], list ) and len (uri ["nodelist" ]) > 0 :
3738 first_node = uri ["nodelist" ][0 ]
3839 if isinstance (first_node , tuple ) and len (first_node ) > 1 and isinstance (first_node [1 ], int ):
3940 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' ]} "
4044
41- return {
45+ url = {
4246 "ENGINE" : "django_mongodb" ,
43- "HOST" : uri ["fqdn" ] or None ,
47+ "NAME" : uri ["database" ],
48+ "HOST" : host ,
4449 "PORT" : port ,
4550 "USERNAME" : uri .get ("username" ),
4651 "PASSWORD" : uri .get ("password" ),
4752 }
53+ return (url )
4854
4955
5056def set_wrapped_methods (cls ):
You can’t perform that action at this time.
0 commit comments