A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.mongodb.com/docs/languages/python/django-mongodb/current/get-started/connect-mongodb/ below:

Configure your MongoDB Connection - Django MongoDB Backend v5.2

After installing Django MongoDB Backend and creating a MongoDB Atlas deployment, you can create a Django project that connects to MongoDB.

From your shell, run the following command to create a new Django project called quickstart based on a custom template:

django-admin startproject quickstart --template https://github.com/mongodb-labs/django-mongodb-project/archive/refs/heads/5.2.x.zip
Note Project Template

The django-mongodb-project template resembles the default Django project template but makes the following changes:

After running this command, your quickstart project has the following file structure:

quickstart/   manage.py   mongo_migrations/       __init__.py       contenttypes/       auth/       admin/   quickstart/       __init__.py       apps.py       settings.py       urls.py       asgi.py       wsgi.py

Open your settings.py file and navigate to the DATABASES setting. Replace this setting with the following code:

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

Replace the <connection string URI> placeholder with the connection string that you copied from the Create a Connection String step of this guide. This configures your Django app to connect to your Atlas deployment and access the sample_mflix sample database.

To verify that you installed Django MongoDB Backend and correctly configured your project, run the following command from your project root:

python manage.py runserver

Then, visit http://127.0.0.1:8000/ . This page displays a "Congratulations!" message and an image of a rocket.

After completing these steps, you have a Django project configured to use MongoDB.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4