Docker
Docker is a linux container which are a type of virtualization. with docker, the entire development environment is isolated: programming language, software packages, databases.
pros and cons
- isolated environment can be reproduced easily and can be shared among team members.
- complexity under the hood may not good to be mess with.
Containers vs Virtual Environments
- Virtual env use to only isolate software packages locally
- Docker is OS level virtualization
Docker in a glance
- install docker
pip install docker-compose
- images and containers
- image is a snapshot in time of what a project contains
- a container is a running instance of the image
- images build
docker image build .
- Dockerized Django: create a Dockerfile for the image can replace Django local dev env.
Django REST Framework
Django REST Framework works alongside the Django web framework to create web APIs.
traditional Django vs Django REST Framework
- Traditional Django is what we learned last week, a single project with multi apps represent different functionalities.
- Django creates websites containing webpages.
- Django REST Framework creates web APIs which are a collection of URL endpoints containing available HTTP verbs that return JSON.
Django REST Framework
- install
pip install djangorestframework
- update settings.py ‘rest_framework’
- create a new URL route, a new view, and a new serializer file
- A serializer is a Json, response for translating complex data request into an easy-to-consume type.
- Browsable API: REST built-in to display both content and HTTP verbs.
- tests: REST provides additional helper classes besides the Django built-in unittest module.
- Deployment: the already learned Heroku.