Change Django's DB to mongodb.
Django 2.2.15 mongodb 4.0.3 djongo 1.3.3 visualstudio 2019
Install django
pip install djongo
Changed Databese in setting.py. Specify the URI of mongodb for host.
setting.py
DATABASES = {
'default': {
#'ENGINE': 'django.db.backends.sqlite3',
#'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'ENGINE': 'djongo',
'NAME': 'your_dbname',
'CLIENT': {
'host': 'mongodb://{user_name}:{pass}@{ip_adress}:{port_num}/{your_dbname}',
}
}
}
Reference https://github.com/nesdis/djongo
Save everything once and close VS. Launch VS, Right click on the project name, python Create superuser Click
Follow the instructions in the interactive window to create a superuser. Make sure to start the project and enter the admin screen. Launch mongodb GUI software and check that django related collections are created in the specified DB.
that's all.
Recommended Posts