Docs Menu
Docs Home
/ / /
Django MongoDB Backend
/

Create a Connection String

You can connect to your MongoDB deployment by providing a connection URI, also called a connection string, which instructs the driver on how to connect to a MongoDB deployment and how to behave while connected.

The connection string includes the hostname or IP address and port of your deployment, the authentication mechanism, user credentials when applicable, and connection options.

1

To retrieve your connection string for the deployment that you created in the previous step, log into your Atlas account and navigate to the Clusters section and click the Connect button for your new deployment.

The connect button in the clusters section of the Atlas UI

Proceed to the Connect your application section and select "Python" from the Driver selection menu and the version that best matches the version you installed from the Version selection menu.

2

Click the button on the right of the connection string to copy it to your clipboard as shown in the following screenshot:

The connection string copy button in the Atlas UI
3

Paste your connection string into a file in your preferred text editor and save this file to a safe location for later use. Your connection string resembles the following example:

mongodb+srv://<db_username>:<db_password>@samplecluster.ojeyz.mongodb.net/?retryWrites=true&w=majority&appName=SampleCluster

Replace the <db_username> and <db_password> placeholders with your database user's username and password.

After completing these steps, you have a connection string that contains your database username, database password, and database name.

Back

Create a MongoDB Deployment