Skip to main content

Requirements

Django REST Framework requires the following versions:

Python

3.10, 3.11, 3.12, 3.13, 3.14

Django

4.2, 5.0, 5.1, 5.2, 6.0
We highly recommend and only officially support the latest patch release of each Python and Django series.

Install Django REST Framework

1

Install using pip

Install the core package:
pip install djangorestframework
You can also install optional packages for additional features:
pip install markdown       # Markdown support for the browsable API
pip install django-filter  # Filtering support
2

Add to INSTALLED_APPS

Add 'rest_framework' to your INSTALLED_APPS setting in settings.py:
settings.py
INSTALLED_APPS = [
    # Django default apps
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    
    # Third-party apps
    "rest_framework",
]
3

Configure browsable API (Optional)

If you want to use the browsable API, add REST framework’s login and logout views to your root urls.py:
urls.py
from django.urls import path, include

urlpatterns = [
    # ...
    path("api-auth/", include("rest_framework.urls")),
]
The URL path can be customized to whatever you prefer.

Optional Packages

Django REST Framework supports several optional packages that enhance functionality:
For automatic schema generation support:
pip install pyyaml uritemplate
  • PyYAML (5.1+) - YAML support for schemas
  • uritemplate (3.0.0+) - URI template parsing
For enhanced browsable API with syntax highlighting:
pip install markdown pygments
  • Markdown (3.3.0+) - Markdown support for the browsable API
  • Pygments (2.7.0+) - Syntax highlighting for code blocks
For advanced filtering and object-level permissions:
pip install django-filter django-guardian
  • django-filter (1.0.1+) - Advanced filtering support
  • django-guardian (1.1.1+) - Object-level permissions

Global Configuration

You can configure global settings for your REST framework API by adding a REST_FRAMEWORK dictionary to your settings.py:
settings.py
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",
    ],
    
    # Enable pagination
    "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
    "PAGE_SIZE": 10,
}
You don’t need to add this configuration initially. REST framework works out of the box with sensible defaults.

Install from Source

If you want to work with the latest development version, you can clone the repository:
git clone https://github.com/encode/django-rest-framework
cd django-rest-framework
pip install -e .
The development version may contain bugs and breaking changes. Use the stable PyPI release for production applications.

Verify Installation

You can verify your installation by running the Django shell:
python manage.py shell
Then import REST framework:
import rest_framework
print(rest_framework.VERSION)
If the import succeeds, you’re ready to start building APIs!

Next Steps

Quick Start

Build your first API in minutes

Tutorial

Learn REST framework step by step

Build docs developers (and LLMs) love