MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Installing DRF0%
Study Materials
REST API Development with DjangoProgress 0%
1.1REST Principles1.2HTTP Methods Overview1.3Status Codes
2.1Installing DRF2.2Serializers Overview2.3Function-Based Views & Class-Based Views
HomeTutorialsREST API Development with DjangoInstalling DRF
Serializers Overview

Installing DRF

Beginner12 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

Installing and Configuring Django REST Framework

Django REST Framework (DRF) is the industry-standard toolkit for building Web APIs in Python. It equips Django with browsable web APIs, serializers, content negotiation, pagination, throttling, and modular authentication schemes. Configuring DRF correctly in settings.py establishes the architectural defaults for your entire API.


1. Installation

1# Install Django REST Framework
2pip install djangorestframework
3 
4# Optional recommended companion packages
5pip install markdown # Markdown support for the browsable API
6pip install django-filter # Advanced filtering backends

Add rest_framework to INSTALLED_APPS:

1# config/settings.py
2INSTALLED_APPS = [
3 # Core Django apps...
4 "django.contrib.admin",
5 "django.contrib.auth",
6 "django.contrib.contenttypes",
7 "django.contrib.sessions",
8 "django.contrib.messages",
9 "django.contrib.staticfiles",
10 
11 # Third-party applications
12 "rest_framework",
13 "django_filters",
14 
15 # Local apps
16 "api",
17]

2. Global REST_FRAMEWORK Configuration

The REST_FRAMEWORK dictionary in settings.py defines global defaults across all endpoints:

1# config/settings.py
2REST_FRAMEWORK = {
3 # 1. Global Authentication Policies
4 "DEFAULT_AUTHENTICATION_CLASSES": [
5 "rest_framework.authentication.SessionAuthentication", # For Browsable API & cookies
6 "rest_framework_simplejwt.authentication.JWTAuthentication", # For SPA & Mobile
7 ],
8 
9 # 2. Global Permission Policies
10 "DEFAULT_PERMISSION_CLASSES": [
11 "rest_framework.permissions.IsAuthenticated", # Secure by default: require login!
12 ],
13 
14 # 3. Global Pagination
15 "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
16 "PAGE_SIZE": 25,
17 
18 # 4. Global Filtering & Search Backends
19 "DEFAULT_FILTER_BACKENDS": [
20 "django_filters.rest_framework.DjangoFilterBackend",
21 "rest_framework.filters.SearchFilter",
22 "rest_framework.filters.OrderingFilter",
23 ],
24 
25 # 5. Global Throttling (Rate Limiting)
26 "DEFAULT_THROTTLE_CLASSES": [
27 "rest_framework.throttling.AnonRateThrottle",
28 "rest_framework.throttling.UserRateThrottle",
29 ],
30 "DEFAULT_THROTTLE_RATES": {
31 "anon": "100/day",
32 "user": "1000/hour",
33 },
34 
35 # 6. Renderers (JSON in production, HTML Browsable API in dev)
36 "DEFAULT_RENDERER_CLASSES": [
37 "rest_framework.renderers.JSONRenderer",
38 "rest_framework.renderers.BrowsableAPIRenderer",
39 ],
40}

3. The Interactive Browsable API

One of DRF's premier features is the Browsable API. When an endpoint is requested via a web browser (Accept: text/html), DRF renders a fully interactive HTML interface allowing developers to inspect JSON outputs, execute test POST / PUT forms, and view response headers directly in the browser!

To enable login/logout in the browsable API, include DRF's authentication views in urls.py:

1# config/urls.py
2from django.urls import path, include
3 
4urlpatterns = [
5 # ... your routes
6 path("api-auth/", include("rest_framework.urls")), # Enables login in browsable UI
7]

4. Production Security: Disabling Browsable API

In high-security production environments, you may wish to disable the HTML Browsable API to save bandwidth and avoid exposing form schemas:

1# In production settings:
2if not DEBUG:
3 REST_FRAMEWORK["DEFAULT_RENDERER_CLASSES"] = [
4 "rest_framework.renderers.JSONRenderer",
5 ]

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
What entry must be added to INSTALLED_APPS in settings.py to activate Django REST Framework?
Question 2
What is the primary benefit of the BrowsableAPIRenderer?
Question 3
Why is configuring DEFAULT_PERMISSION_CLASSES: ['rest_framework.permissions.IsAuthenticated'] considered an enterprise security best practice?
Question 4
What does adding path("api-auth/", include("rest_framework.urls")) enable in urls.py?
Question 5
What is the purpose of DEFAULT_RENDERER_CLASSES in DRF settings?
Next Lesson

Serializers Overview

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Status CodesSerializers Overview

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master REST API Development with Django with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext