Skip to content

DOCSP-51035: parse_uri() options #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions source/connect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ function accepts the following arguments:

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

Expand All @@ -160,8 +162,12 @@ example:

import django_mongodb_backend

MONGODB_URI = "mongodb+srv://my_user:[email protected]/?retryWrites=true&w=majority"
DATABASES["default"] = django_mongodb_backend.parse_uri(MONGODB_URI, db_name="<database name>")
MONGODB_URI = "mongodb+srv://my_user:[email protected]/"
DATABASES["default"] = django_mongodb_backend.parse_uri(
MONGODB_URI,
db_name="<database name>",
options={"retryWrites": True, "w": "majority"}
)

Additional Information
----------------------
Expand Down
Loading