Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

SEC ­ BACK END WEB DEVELOPMENT

NAME – PRAGATI CHAUHAN


ROLL NO. – 2022/813
COURSE – B.A.(HONS.) ENGLISH
SEMESTER – 4TH

CLASSWORK ­ 17/02/2024

Creation of a basic API using Django Rest Framework.

STEPS TO BE FOLLOWED FOR CREATION OF API USING DJANGO REST FRAMEWORK are as follows –

Step 1 –

pip install django_rest_framework

Step 2 –

django-admin startproject proj

cd proj

Step 3-

In proj/se ngs.py, add ‘rest_framework’ at the bo om to create api in python Django


Step 4 –

Add this app to INSTALLED_APPS of se ngs.py in proj/se ngs.py

Step 5-

Now, add APIs urls in proj/urls.py.

Step 6-

In rest_apis_app/models.py
Step 7 –

Create serializers.py in rest_apis_app

Step 8 –

In rest_apis_app/views.py
Step 9 –

In rest_apis_app/urls.py

Step 10 –

python manage.py makemigra ons

python manage.py migrate

python manage.py runserver

OUTPUT :
CUSTOM VIEWS GET AND POST METHODS

1. POST

OUTPUT:
2. GET

OUTPUT:
Create the superuser so that we can access the Django admin dashboard
python manage.py createsuperuser

Register the created model in the models/admin.py

python manage.py runserver

OUTPUT:

You might also like