Skip to content

DOCSP-47875: Add new parse_uri parameter #26

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 2 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions source/connect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ your MongoDB connection, you can use the ``parse_uri()`` function. This
function accepts the following arguments:

- ``uri``: Your MongoDB connection URI.
- ``db_name``: The name of the database you want to use.
- ``conn_max_age``: Configures persistent database connections.
This argument is optional. To learn more, see
`Persistent connections <{+django-docs+}/ref/databases/#persistent-database-connections>`__
Expand All @@ -165,8 +166,8 @@ example:

import django_mongodb_backend

MONGODB_URI = "mongodb+srv://my_user:[email protected]/my_database?retryWrites=true&w=majority"
DATABASES["default"] = django_mongodb_backend.parse_uri(MONGODB_URI)
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>")

Additional Information
----------------------
Expand Down
2 changes: 1 addition & 1 deletion source/get-started/connect-mongodb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ you can create a {+framework+} project that connects to MongoDB.
.. code-block:: python

DATABASES = {
"default": django_mongodb_backend.parse_uri("<connection string URI>"),
"default": django_mongodb_backend.parse_uri("<connection string URI>", db_name="<database name>"),
}

Replace the ``<connection string URI>`` placeholder with the connection string
Expand Down
Loading