Skip to content

DRF

Extending Django with DRF

This book also includes a dedicated chapter on Django REST Framework (DRF), as a natural extension to Django. In many modern projects, Django is used purely as a backend service, with frontend built in frameworks like React, Vue, or Angular. In such cases, Django’s role is to provide a robust and secure API that powers the frontend application.

DRF extends Django with powerful tools for building RESTful APIs. Learning it alongside Django gives you the flexibility to build either full-stack applications with Django or API-driven backends with Django + DRF.

Install Django REST Framework (DRF)

  • Install DRF using the following command:
shell
pip install djangorestframework
  • You can optionally install following packages as well:
shell
pip install markdown                      # Markdown support for the browseable API.
pip install django-filter                 # Filtering support.
pip install drf-spectacular               # Schema generation support.
pip install djangorestframework-simplejwt # JSON Web Token authentication plugin for DRF.

DRF setup

To set up Django REST Framework (DRF) for your project, add it to the INSTALLED_APPS list in your settings.py file:

python
# my_site/settings.py
INSTALLED_APPS = [
    ...
    'rest_framework',
]

(This enables DRF in your project, allowing you to build RESTful APIs.)

Last updated: