Skip to content

Commit e819619

Browse files
committed
DOCSP-51035: parse_uri() options
1 parent 5fcd185 commit e819619

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

source/connect.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,10 @@ function accepts the following arguments:
144144

145145
- ``uri``: Your MongoDB connection URI.
146146
- ``db_name``: The name of the database you want to use.
147-
- ``test``: Provides a dictionary of settings for test
148-
databases. This argument is optional. To learn more, see
147+
- ``options``: *(Optional)* A dictionary of options to apply to the connection.
148+
These options take precedence over any duplicate options specified in the URI.
149+
- ``test``: *(Optional)* Provides a dictionary of settings for test
150+
databases. To learn more, see
149151
`the TEST setting <{+django-docs+}/ref/settings/#test>`__
150152
in the {+framework+} documentation.
151153

@@ -160,8 +162,12 @@ example:
160162

161163
import django_mongodb_backend
162164

163-
MONGODB_URI = "mongodb+srv://my_user:[email protected]/?retryWrites=true&w=majority"
164-
DATABASES["default"] = django_mongodb_backend.parse_uri(MONGODB_URI, db_name="<database name>")
165+
MONGODB_URI = "mongodb+srv://my_user:[email protected]/"
166+
DATABASES["default"] = django_mongodb_backend.parse_uri(
167+
MONGODB_URI,
168+
db_name="<database name>",
169+
options={"retryWrites": "true", "w": "majority"}
170+
)
165171

166172
Additional Information
167173
----------------------

0 commit comments

Comments
 (0)