Python3, Django, MongoDB(docker)

Steps I did to get Python3, Django and MongoDB working on my Mac.

Environment

Anaconda is installed

Result

Steps taken

Created an env in anaconda called ‘django’

Activate virtual environment in terminal

conda activate Django

Create path for django application  and check django version

mkdir django-apps
cd django-apps/
django-admin --version

Create your app

django-admin startproject testproject

If you want you can test with the standard sqlite3 now with ‘python manage.py runserver’

Install the django – mongo connector

pip install djongo

Change the database in settings.py

vi settings.py

now change

DATABASES = {
   'default' : {
      'ENGINE' : 'djongo',
      'NAME' : 'mydbname',
   }
}

Container MongoDB

docker run -d -p 27017-27019:27017-27019 –name django-mongo -v /Users/myusername/Documents/Data/MongoDB/:/data/db -d mongo

Run the django app

python manage.py runserver