Skip to content

Installation

Getting started with DRF is straightforward.

Prerequisites

  • Python (3.6+)
  • Django (3.0+)

Step-by-step Guide

  1. Install using pip:

    bash
    pip install djangorestframework
  2. Add to INSTALLED_APPS: Open your project's settings.py and add 'rest_framework' to your installed apps.

    python
    INSTALLED_APPS = [
        ...
        'rest_framework',
    ]
  3. Global Settings (Optional): You can configure global DRF settings in settings.py using the REST_FRAMEWORK dictionary.

    python
    REST_FRAMEWORK = {
        # Use Django's standard `django.contrib.auth` permissions,
        # or allow read-only access for unauthenticated users.
        'DEFAULT_PERMISSION_CLASSES': [
            'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
        ]
    }

Optional Packages

None of these are required, but each adds a capability you are likely to want as an API grows:

bash
pip install markdown                      # Markdown support for the browsable 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.
pip install drf-writable-nested           # Nested create and update support for serializers.