Install djongo
pip install djongo
Create your project dir
mkdir chillzeeTest
Go to your project directory and set up django project.
cd chillzeeTest
django-admin startproject ChillzeeTestSite
Edit settings.py and update database settings.
DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': 'chillzeeproject',
}
}
Run the following command to apply database changes to your django project
python manage.py migrate
Visit http://127.0.0.1:8000/ to make sure that your django project is up and running
Go to MongoDB and see if the database has been created by django.
show dbs
In our example, django has created the chillzeeproject database.
We will now see the collections to make sure that every thing went fine.
use chillzeeproject
show collections
Now you can update your models.py file to work on your new mongoDB database, just as you would do with any other database like postgres or mysql.
So that’s it friends! As you could see connecting MongoDB to django has become much simpler now.
Long live open source community!