Pythie
CategoriesTrending
An open index of Python tools.Pythie’s IndexLegal noticePrivacyData: PyPI (package metadata; download statistics under CC BY 4.0, via ClickHouse), deps.dev (CC BY 4.0), GitHub, OSV.

djangorestframework

3.18.3ActivePythie’s Index: 92

Web APIs for Django, made easy.

Actively maintained. Last release 8 weeks ago, commits in 22 of the last 26 weeks. A safe choice.

Web FrameworksValidation & Serialization
$pip install djangorestframework
encode/django-rest-frameworkHomepagePyPI

Django REST framework

build-status-image coverage-status-image pypi-version

Awesome web-browsable Web APIs.

Full documentation for the project is available at https://www.django-rest-framework.org/.


Overview

Django REST framework is a powerful and flexible toolkit for building Web APIs.

Some reasons you might want to use REST framework:

  • The Web browsable API is a huge usability win for your developers.
  • Authentication policies including optional packages for OAuth1a and OAuth2.
  • Serialization that supports both ORM and non-ORM data sources.
  • Customizable all the way down - just use regular function-based views if you don't need the more powerful features.
  • Extensive documentation, and great community support.

Below: Screenshot from the browsable API

Screenshot


Requirements

  • Python 3.10+
  • Django 5.2, 6.0, 6.1

We highly recommend and only officially support the latest patch release of each Python and Django series.

Installation

Install using pip...

pip install djangorestframework

Add 'rest_framework' to your INSTALLED_APPS setting.

INSTALLED_APPS = [
    # ...
    "rest_framework",
]

Example

Let's take a look at a quick example of using REST framework to build a simple model-backed API for accessing users and groups.

Start up a new project like so...

pip install django
pip install djangorestframework
django-admin startproject example .
./manage.py migrate
./manage.py createsuperuser

Now edit the example/urls.py module in your project:

from django.contrib.auth.models import User
from django.urls import include, path
from rest_framework import routers, serializers, viewsets


# Serializers define the API representation.
class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = User
        fields = ["url", "username", "email", "is_staff"]


# ViewSets define the view behavior.
class UserViewSet(viewsets.ModelViewSet):
    queryset = User.objects.all()
    serializer_class = UserSerializer


# Routers provide a way of automatically determining the URL conf.
router = routers.DefaultRouter()
router.register(r"users", UserViewSet)

# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
    path("", include(router.urls)),
    path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
]

We'd also like to configure a couple of settings for our API.

Add the following to your settings.py module:

INSTALLED_APPS = [
    # ... make sure to include the default installed apps here.
    "rest_framework",
]

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",
    ]
}

That's it, we're done!

./manage.py runserver

You can now open the API in your browser at http://127.0.0.1:8000/, and view your new 'users' API. If you use the Login control in the top right corner you'll also be able to add, create and delete users from the system.

You can also interact with the API using command line tools such as curl. For example, to list the users endpoint:

$ curl -H 'Accept: application/json; indent=4' -u admin:password http://127.0.0.1:8000/users/
[
    {
        "url": "http://127.0.0.1:8000/users/1/",
        "username": "admin",
        "email": "admin@example.com",
        "is_staff": true,
    }
]

Or to create a new user:

$ curl -X POST -d username=new -d email=new@example.com -d is_staff=false -H 'Accept: application/json; indent=4' -u admin:password http://127.0.0.1:8000/users/
{
    "url": "http://127.0.0.1:8000/users/2/",
    "username": "new",
    "email": "new@example.com",
    "is_staff": false,
}

Documentation & Support

Full documentation for the project is available at https://www.django-rest-framework.org/.

For questions and support, use the REST framework discussion group, or #restframework on libera.chat IRC.

Security

Please see the security policy.

Popularity

Downloads / month
30M
GitHub stars
30.3K
Downloads, last 7 days
6.6M-5%
Stars, last 7 days
–
Direct dependents
2.2K
All dependents
3.2K

Pythie’s Index

How it works
92

Healthy

Maintenance, out of 100

  • Recent release

    last release 53 days ago

  • Commit activity

    22/26 weeks with commits

  • Release cadence

    7 releases in 12 months

  • Issues & PRs handled

    70% closed in the past year

  • Contributor spread

    45 authors in last 100 commits

  • OpenSSF Scorecard

    6.3/10

Commits, last 26 weeks109

Releases

Latest
3.18.3
Released
Oct 6, 2026
Releases, 12 months
7
First release
Feb 21, 2011

Compatibility

Requires Python
>=3.10
Tested on
3.10 · 3.11 · 3.12 · 3.13 · 3.14 · 3.15
License
BSD-3-Clause (Permissive)

Keywords

pythondjangoapirest

Alternatives

Use instead of djangorestframework: tools that do the same job, closest first.

Compare with django-ninja →Compare with django-rest-framework →Compare with fastapi →Compare all 4 →

  • django-ninja1.8.0ActivePythie’s Index: 84

    Django Ninja - Fast Django REST framework

    Web FrameworksDocs & Templating9.3K5.3M/moReleased Nov 8, 2026
  • django-rest-framework0.1.0InactivePythie’s Index: 19

    alias.

    Web Frameworks–101K/moReleased Jul 20, 2017
  • fastapi0.165.0ActivePythie’s Index: 86

    FastAPI framework, high performance, easy to learn, fast to code, ready for production

    Web Frameworks105K561.9M/moReleased Nov 18, 2026
  • django-tastypie0.15.1MaintainedPythie’s Index: 24

    A flexible & capable API layer for Django.

    Web FrameworksValidation & Serialization3.9K170K/moReleased Feb 23, 2025

Works well with

Use together with djangorestframework: extensions, drivers, servers and companion tools.

  • DjangoPythie’s Index: 91A high-level Python web framework that encourages rapid development and clean, pragmatic design.52.8M downloads/mo
  • drf-spectacularPythie’s Index: 47Sane and flexible OpenAPI 3 schema generation for Django REST framework16.8M downloads/mo
  • djangorestframework-simplejwtPythie’s Index: 36A minimal JSON Web Token authentication plugin for Django REST Framework8.3M downloads/mo
  • drf-nested-routersPythie’s Index: 68Nested resources for the Django Rest Framework2.7M downloads/mo
  • dj-rest-authPythie’s Index: 48Authentication and Registration in Django Rest Framework1M downloads/mo
  • djangorestframework-dataclassesPythie’s Index: 21A dataclasses serializer for Django REST Framework3.1M downloads/mo