Skip to content

Commit 83c59cb

Browse files
committed
Integrate Django with MongoDB
1 parent 4116d6a commit 83c59cb

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

docs/technologies/django/integrate-mongodb.mdx

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
---
2-
title: Integrate Django with MongoDB
3-
description: Learn how to integrate Django with MongoDB
2+
title : Integrate Django with MongoDB
3+
sidebar_label : Django and MongoDB
44
---
55

6-
import SubHeading from "@site/src/components/SubHeading";
6+
# Integrate Django with MongoDB
77

8-
<SubHeading color="#25c2a0">Learn how to integrate Django with MongoDB</SubHeading>
8+
<SubHeading>Learn how to integrate Django with MongoDB</SubHeading>
99

1010
This page explains `how to integrate` **Django with MongoDB**, two powerful and technologies used in many applications and production-ready projects.
11+
1112
The `source code` is saved on GitHub for later reference and support.
1213

1314
- 👉 [Integrate Django & Mongo](https://github.com/app-generator/how-to-integrate-django-with-mongo) - `sample project`
@@ -17,11 +18,11 @@ The `source code` is saved on GitHub for later reference and support.
1718

1819
<br />
1920

20-
## Introduction
21+
## Introduction
2122

2223
This section presents more insights regarding `MongoDB` and the power features compared to a `Relational Database` like MySql or PostgreSQL.
2324

24-
### What is MongoDB
25+
### What is MongoDB
2526

2627
`MongoDB` is an open-source, document-oriented NoSQL database that was designed for scalability and high availability.
2728
MongoDB stores data in JSON-like documents, which makes it easy for developers to work with data because it does not require a fixed schema.
@@ -30,7 +31,7 @@ This means you can store data without having to define a strict structure, which
3031
MongoDB supports CRUD (Create, Read, Update, Delete) operations, ad-hoc queries, and indexing, making it an excellent choice for modern web and mobile applications.
3132
It is widely used across various industries because of its flexibility, scalability, and fast performance.
3233

33-
### MongoDB vs Relational DBMS
34+
### MongoDB vs Relational DBMS
3435

3536
> **Data Model**
3637
@@ -54,7 +55,7 @@ Relational databases are well-suited for transactional systems, such as online b
5455

5556
<br />
5657

57-
## Install MongoDB
58+
## Install MongoDB
5859

5960
For this tutorial, you need MongoDB installed on your device to get started. To install MongoDB follow the links below and follow the steps outlined to get it done.
6061

@@ -75,7 +76,7 @@ $ sudo systemctl start mongod
7576

7677
<br />
7778

78-
## MongoDB shell
79+
## MongoDB shell
7980

8081
`Mongosh`, the MongoDB shell is used to interact with the **MongoDB** server from the terminal. For Linux, it is installed with the MongoDB server.
8182
For Windows `mongosh` is not installed with the MongoDB server, and needs to be installed from this location:
@@ -99,7 +100,7 @@ This shows that `mongosh` has successfully connected to the MongoDB server. Now
99100

100101
<br />
101102

102-
## Create a `Django` Project
103+
## Create a `Django` Project
103104

104105
From the terminal run the following commands to create a new folder, change the directory into the new folder and create a new virtual environment
105106

@@ -137,7 +138,7 @@ The project is created in the current directory because of `.` added to the comm
137138

138139
<br />
139140

140-
### Add dependencies for `MongoDB`
141+
### Add dependencies for `MongoDB`
141142

142143
Django was built to integrate seamlessly with Relational Databases.
143144
To use MongoDB with Django and still leverage features like the database modeling, admin panel and so on, we will be needing a package called `Djongo`.
@@ -151,7 +152,7 @@ The proceeding steps will help us install and configure our Django project to us
151152

152153
<br />
153154

154-
### Update Configuration for `MongoDB`
155+
### Update Configuration for `MongoDB`
155156

156157
Open `core/settings.py` and make the following changes to allow Django uses `djongo` as the database engine.
157158

@@ -169,7 +170,7 @@ DATABASES = {
169170

170171
<br />
171172

172-
### Create a Superuser
173+
### Create a Superuser
173174

174175
Before creating a superuser, we need to apply the default database migration.
175176
Run the command below to apply database migration and then create a superuser
@@ -185,11 +186,11 @@ Now you can start the application and visit the admin panel using the superuser
185186

186187
<br />
187188

188-
## Checking the information
189+
## Checking the information
189190

190191
just to double check the set up, we can access the `admin` section (reserved for superusers) or use the Django CLI to inspect the information.
191192

192-
### Accessing the `ADMIN` Section
193+
### Accessing the `ADMIN` Section
193194

194195
Run the application using the command below
195196

@@ -212,7 +213,7 @@ This is the route to the admin section. Once you log in you will see the admin p
212213

213214
<br />
214215

215-
### Visualizing the data in `MongoDB`
216+
### Visualizing the data in `MongoDB`
216217

217218
To see the data added to your database, open your terminal and run the following command
218219

@@ -268,21 +269,21 @@ This command will return a list of all the users registered. For now, we have on
268269

269270
<br />
270271

271-
## Style the Project
272+
## ✅ Styling the Project
272273

273274
This section explains how to style the project with a an open-source theme that covers the admin section but also the rest of the website.
274275

275276
The theme to be added is the [Django Soft Dashboard](https://github.com/app-generator/django-admin-soft-dashboard), a modern **Bootstrap 5** Design from Creative-Tim, migrated to Django.
276277

277278
The proceeding steps will guide you in integrating this theme with your Django project.
278279

279-
> `Install the theme`
280+
> `Install the theme`
280281
281282
```bash
282283
(venv) $ pip install django-admin-soft-dashboard
283284
```
284285

285-
> `Update Settings`
286+
> `Update Settings`
286287
287288
After installation, we need to make changes to our project files to allow the project to recognize and use the theme. Open the file `core/settings.py` and make the following changes.
288289

@@ -304,7 +305,7 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
304305
# ... (truncated content)
305306
```
306307

307-
> `Edit Routes`
308+
> `Edit Routes`
308309
309310
Next step is to add a route that points to the theme. Open `core/urls.py and make the following change
310311

@@ -337,7 +338,7 @@ At this point, our Django & MongoDB project is also styled with a nice, modern d
337338

338339
<br />
339340

340-
## Conclusions
341+
## Conclusions
341342

342343
Congratulations on completing the tutorial, so far we have covered the basics of setting up a Django project, connecting Django with MongoDB,
343344
viewing data stored in our MongoDB database and also using a prebuilt theme to get a head start in developing a Django application.
@@ -348,8 +349,10 @@ With the power of Django's web framework and MongoDB's scalability and high avai
348349
By following the above steps, you'll be able to connect Django to MongoDB quickly and begin building powerful and scalable web applications.
349350
You can visit [Appseed](https://appseed.us/) for more templates like the one used for this tutorial.
350351

351-
## Resources
352+
<br />
353+
354+
## ✅ Resources
352355

353-
- 👉 [Djongo Documentation](https://www.djongomapper.com/get-started/)
354-
- 👉 [Django Soft Admin Dashboard](https://github.com/app-generator/django-admin-soft-dashboard)
355-
- 🚀 Free [Support](https://appseed.us/support/) via Email & Discord
356+
- 👉 Access [AppSeed](https://appseed.us/) and start fast your next project
357+
- 👉 [Deploy Projects on Aws, Azure and Digital Ocean](https://www.docs.deploypro.dev/) via **DeployPRO**
358+
- 👉 Create an amazing landing page with [Simpllo, an open-source site builder](https://www.simpllo.com/)

0 commit comments

Comments
 (0)