How to set Django DB to mongodb visual studio 2019

Change Django's DB to mongodb.

environment

Django 2.2.15 mongodb 4.0.3 djongo 1.3.3 visualstudio 2019

procedure

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 名称未設定 1.jpg

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. コレクション.jpg

that's all.

Recommended Posts

How to set Django DB to mongodb visual studio 2019
How to install Google Test / Google Mock in Visual Studio 2019
How to use linux commands in Visual Studio Code terminal
How to debug the Python standard library in Visual Studio
[Django] How to test Form [TDD]
How to reflect CSS in Django
How to get started with Django
How to write Django1.9 environment-independent wsgi.py
How to build MongoDB C driver
How to authenticate with Django Part 2
How to authenticate with Django Part 3
How to do arithmetic with Django template
[Blender] How to set shape_key with script
How to set optuna (how to write search space)
How to hide the command prompt when running python in visual studio 2015
How to check the version of Django
How to set up SVM using Optuna
How to set the server time to Japanese time
How to delete expired sessions in Django
How to set xg boost using Optuna
[Development environment] How to create a data set close to the production DB
How to do Server-Sent Events in Django
How to convert DateTimeField format in Django
How to implement Rails helper-like functionality in Django
How to set up Random forest using Optuna
How to set browser location in Headless Chrome
How to develop a cart app with Django
How to reflect ImageField in Django + Docker (pillow)
How to run some script regularly in Django
[Django] How to get data by specifying SQL.
How to print debug messages to the Django console
Django with Python Tools 2.2 for Visual Studio (PTVS 2.2)
How to implement "named_scope" of RubyOnRails with Django
How to set up Random forest using Optuna
How to set up a local development server
How to create a Rest Api in Django
How to set CPU affinity for process threads
How to get started with Visual Studio Online ~ The end of the environment construction era ~
How to set up public key authentication in ssh
[Python] [Django] How to use ChoiceField and how to add options
How to get multiple model objects randomly in Django
How to set up a Python environment using pyenv
Preparing to use Tensorflow (Anaconda) with Visual Studio Code
How to deploy a Django application on Alibaba Cloud
App development to tweet in Python from Visual Studio 2017
How to use Azure Table storage from Django (PTVS)
Set the form DateField to type = date in Django
How to build a Django (python) environment on docker
How to use bootstrap in Django generic class view
How to set layer on Lambda using AWS SAM
[Blender] How to dynamically set the selection of EnumProperty
[Introduction to Udemy Python3 + Application] 30. How to use the set
How to upload files in Django generic class view
Until you run server Django in Visual Studio Code
How to use Django on Google App Engine / Python
How to use Decorator in Django and how to make it
How to run Django on IIS on a Windows server
How to reference static files in a Django project
How to set up and compile your Cython environment
[Django] How to redirect unlogged-in users to the login page
How to unprefix the DB name used by pytest-django