Skip to content

Commit 1c06aec

Browse files
committed
parse_uri edits
1 parent ecff738 commit 1c06aec

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

source/django-get-started/django-connect-mongodb.txt

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,10 @@ you can create a Django project that connects to MongoDB.
6464
.. code-block:: bash
6565

6666
DATABASES = {
67-
"default": {
68-
"ENGINE": "django_mongodb_backend",
69-
"NAME": "sample_mflix",
70-
"USER": "<username>",
71-
"PASSWORD": "<password>",
72-
"HOST": "<connection string URI>",
73-
},
67+
"default": django_mongodb_backend.parse_uri("<connection string URI>"),
7468
}
7569

76-
Replace the ``<username>`` and ``<password>`` placeholders with your
77-
Atlas database user's username and password. Then, replace the
78-
``<connection string URI>`` placeholder with the connection string
70+
Replace the ``<connection string URI>`` placeholder with the connection string
7971
that you copied from the :ref:`django-get-started-connection-string`
8072
step of this guide. This configures your Django app to connect to
8173
your Atlas deployment and access the ``sample_mflix`` sample database.

source/django-get-started/django-connection-string.txt

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,28 @@ To connect to an instance or deployment not hosted on Atlas, see
4343
.. figure:: /includes/figures/atlas_connection_copy_string_python.png
4444
:alt: The connection string copy button in the Atlas UI
4545

46-
.. step:: Update the placeholders
46+
.. step:: Edit and save the connection string
4747

48-
Paste this connection string into a file in your preferred text editor
49-
and replace the ``<username>`` and ``<password>`` placeholders with
48+
Paste your connection string into a file in your preferred text editor
49+
and save this file to a safe location for use in the next step.
50+
Your connection string resembles the following example:
51+
52+
.. code-block:: none
53+
54+
mongodb+srv://<username>:<password>@cluster0.example.mongodb.net/?retryWrites=true&w=majority
55+
56+
57+
Replace the ``<username>`` and ``<password>`` placeholders with
5058
your database user's username and password.
59+
60+
Then, specify a connection to the ``sample_mflix`` database from the
61+
Atlas sample datasets by adding it after the hostname, as shown in
62+
the following example:
5163

52-
Save this file to a safe location for use in the next step.
64+
.. code-block:: none
65+
66+
mongodb+srv://<username>:<password>@cluster0.example.mongodb.net/sample_mflix?retryWrites=true&w=majority
5367

5468
After completing these steps, you have a connection string that
55-
contains your database username and password.
69+
contains your database username, database password, and database name.
5670

source/django-get-started/django-create-app.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ To learn more about the ``sample_mflix`` database, see :atlas:`Sample Mflix Data
5555
released = models.DateTimeField("release date", null=True, blank=True)
5656
awards = EmbeddedModelField(Award)
5757
genres = ArrayField(models.CharField(max_length=100), null=True, blank=True)
58-
objects = MongoManager()
5958

6059
class Meta:
6160
db_table = "movies"

source/django-get-started/django-query-data.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ to read data from the ``sample_mflix`` database.
4040
.. code-block:: bash
4141
:copyable: false
4242

43-
<QuerySet [<Viewer: Khal Drogo>]>
43+
<Viewer: Khal Drogo>
4444

4545
.. step:: Query the "movies" collection for specified runtime values
4646

0 commit comments

Comments
 (0)