Simple Django Rest Framework

Official django rest framework site here.

Step 1: Preparation
a. Create virtual environtment: virtualenv env
b. Activate virtual environement: venv\Scripts\activate
c. Install django, django rest framwork:
pip install django djangorestframework

Step 2: Create project
a. Create project: django-admin startproject myproject
b. Go to myproject folder: cd myproject

Step 3: Create app
a. Create app: python manage.py startapp myapp
b. Add myapp and djangorestframework in INSTALLED_APPS myproject/settings.py

Step 4: Create Model, Serializer and ViewSet
a. Create Model, Serializer and ViewSet in myapp/models.py

Step 5: Setup URLs
a. Add urls.py in myapp folder. myapp/urls.py

b. Update myproject/urls.py

Step 6: Make Migration and Migrate
a. Make migration: python manage.py makemigrations
b. Migrate: python manage.py migrate

Step 7: Run Server
a. Run server: python manage.py runserver
b. Access browser: http://127.0.0.1:8000/

API root
GET /book/
HTML Form to add Book

Software Engineer