pip install virtualenv
python3.6 -m venv venv
source venv/bin/activate
pip install django
pip install djangorestframework
pip install django-rest-knox
pip install django-filter
django-admin startproject Website
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'REST',
'django_filters'
]
python manage.py runserver
django-admin startapp REST
python3.6 manage.py migrate
python3.6 manage.py makemigrations
python3.6 manage.py createsuperuser
python3.6 manage.py migrate
urls.py
serializer.py
from rest_framework.response import Response
from rest_framework import status
from django.shortcuts import get_object_or_404
from rest_framework.views import APIView
#Create your views here.
class Person(APIView):
def get(self, request, format=None):
message = {
'Response':200,
'Message' : 'Welcome to django rest API'
}
return Response(message)
from django.contrib import admin
from django.urls import path, include
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('RESTAPI.urls')),
]
from django.urls import path, include
from django.conf.urls import url
from rest_framework.urlpatterns import format_suffix_patterns
from . import views
urlpatterns = [
path('', views.PersonView.as_view()),
]