Skip to content

Commit b6966ee

Browse files
committed
DOCSP-47875: Add new parse_uri parameter
1 parent de6d4d7 commit b6966ee

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

source/connect.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ your MongoDB connection, you can use the ``parse_uri()`` function. This
145145
function accepts the following arguments:
146146

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

166167
import django_mongodb_backend
167168

168-
MONGODB_URI = "mongodb+srv://my_user:[email protected]/my_database?retryWrites=true&w=majority"
169-
DATABASES["default"] = django_mongodb_backend.parse_uri(MONGODB_URI)
169+
MONGODB_URI = "mongodb+srv://my_user:[email protected]/?retryWrites=true&w=majority"
170+
DATABASES["default"] = django_mongodb_backend.parse_uri(MONGODB_URI, db_name="<database name>")
170171

171172
Additional Information
172173
----------------------

source/get-started/connect-mongodb.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ you can create a {+framework+} project that connects to MongoDB.
6464
.. code-block:: python
6565

6666
DATABASES = {
67-
"default": django_mongodb_backend.parse_uri("<connection string URI>"),
67+
"default": django_mongodb_backend.parse_uri("<connection string URI>", db_name="<database name>"),
6868
}
6969

7070
Replace the ``<connection string URI>`` placeholder with the connection string

0 commit comments

Comments
 (0)