DRF

Introduction To Django rest Framework

blog image

Django REST Framework (DRF) is a powerful and flexible toolkit for building Web APIs in Python. It is built on top of Django, a popular web framework for Python, and provides many useful features and utilities for creating and testing APIs.

DRF allows developers to quickly and easily build APIs using a wide range of views, serializers, and authentication mechanisms. It also provides a number of built-in tools for handling common tasks such as pagination, filtering, and content negotiation.

Some of the key features of DRF include:

  • Support for a wide range of HTTP methods and status codes
  • Serialization of complex data types, including nested data and relationships between objects
  • Support for multiple authentication schemes, including basic authentication, token-based authentication, and OAuth
  • Built-in support for pagination, filtering, and content negotiation
  • A browsable API interface for easy testing and exploration of APIs

DRF is widely used in industry and is a popular choice for building RESTful APIs with Python. It is well-documented and has a large and active community of users and contributors.

Django REST framework is a powerful and flexible toolkit for building Web APIs. It allows end-users to access, write, update and delete data using the HTTP methods.

There areFive HTTP methods:

  • GET — used to retrieve data
  • POST — used to write data
  • PUT — used to update data
  • PATCH — used to partial update data
  • DELETE — used to delete data

 

Install DRF

1. pip install django_restframework

2.Installing DRF to django project by mentioning it in INSTALLED_APP

INSTALLED_APP=[

      'rest_framework',

]

 

How To Render Api Data In JSON Format 

#settings.py
REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
    )
}

 

Or add ?formate=JSON at end of API URL

/api/v1/post/?format=json

About author

author image

Amrit Panta

Python developer, content writer



3 Comments

Amanda Martines 5 days ago

Exercitation photo booth stumptown tote bag Banksy, elit small batch freegan sed. Craft beer elit seitan exercitation, photo booth et 8-bit kale chips proident chillwave deep v laborum. Aliquip veniam delectus, Marfa eiusmod Pinterest in do umami readymade swag. Selfies iPhone Kickstarter, drinking vinegar jean.

Reply

Baltej Singh 5 days ago

Drinking vinegar stumptown yr pop-up artisan sunt. Deep v cliche lomo biodiesel Neutra selfies. Shorts fixie consequat flexitarian four loko tempor duis single-origin coffee. Banksy, elit small.

Reply

Marie Johnson 5 days ago

Kickstarter seitan retro. Drinking vinegar stumptown yr pop-up artisan sunt. Deep v cliche lomo biodiesel Neutra selfies. Shorts fixie consequat flexitarian four loko tempor duis single-origin coffee. Banksy, elit small.

Reply

Leave a Reply

Scroll to Top