Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
D

django-rest-framework

> 后端框架
Open source

Web APIs for Django. 🎸

30.1K stars0 likes9 views
WebsiteGitHub

About

Web APIs for Django. 🎸

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...

bash
pip install djangorestframework

Add 'rest_framework' to your INSTALLED_APPS setting.

python
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...

bash
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:

…

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

Add the following to your settings.py module:

python
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": "[email protected]",
        "is_staff": true,
    }
]

Or to create a new user:

$ curl -X POST -d username=new -d [email protected] -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": "[email protected]",
    "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.

Issues· 49 open

View all issuesOpen on GitHub
  • #8926

    Invalid `self.instance` when validating the serializer using `many=True`

    BugNeeds design decisionUpdated Sep 24, 2026
  • #9179

    Not possible to override serializer_field_mappings with a field that has choices (for example a from ChoiceField derived field)

    Updated Sep 19, 2026
  • #7953

    "No POST data" in error report

    Updated Sep 12, 2026
  • #7134

    ModelSerializer uniqueness check crashes with OverflowError and that crash can not be prevented with field-level validation

    Updated Sep 12, 2026
  • #6341

    Model unique_for_month changes ability to partially update ModelSerializer

    Updated Sep 12, 2026
  • #3460

    Document that explicitly declared fields will not have their attributes overridden by `read_only_fields` shortcut.

    DocumentationUpdated Aug 30, 2026
  • #9747

    a viewset's action list gets "head" added to it, but only after being called at least once

    Updated Aug 20, 2026
  • #8273

    `required: True` set on a nullable field which is included in combined_unique

    Needs design decisionUpdated Aug 7, 2026
  • #5236

    TemplateHTMLRenderer - TypeError - context must be a dict rather than ReturnList.

    BugUpdated Apr 27, 2026
  • #3070

    Partial updates and object-level validations

    DocumentationUpdated Mar 11, 2026

> Tags

Pythonapidjangopythonrest

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 30, 2026
Category后端框架
PricingOpen source

> Related tools

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架