SlideShare a Scribd company logo
2
Most read
3
Most read
7
Most read
Introduction to Django REST Framework, an easy way to build REST framework in Django
● developer@keycrunch & founder@offerqa
● built REST api in Django since 2013
follow me on twitter @linuxcity
who am I?
What is REST?
http://en.wikipedia.org/wiki/Representational_State_Transfer
Web API that uses GET, POST, PUT, PATCH, DELETE operations over HTTP.
What do you need from a framework
● serialization and deserialization
● pagination
● data validation
● authentication
● custom queryset
● proper HTTP response handling (errors, format and such)
● caching
● throttling
● permissions
Good to have
● Really good test coverage of their code
● Decent performance
● Documentation
● An active community to advance and support the framework
And Django REST Framework has them all!!!
Why Django REST framework
● Class-based views
● it’s very django-ish
...As it's based off Django 1.3 style Class Based Views (CBVs), it has a
very familiar pattern. Actually, because of the quality of the documentation,
I really prefer using django-rest-framework CBVs more than using Django's
actual CBVs…
-from http://pydanny.com/choosing-an-api-framework-for-django.html
● neat design
...
And Most of All
I enjoyed working with it
Requirement
Django >1.4.11
so if you are still on Django 1.3, it’s time to
update. And you should have done that three
years ago!
a minimal REST API
models.py
class Post(models.Model):
post = models.TextField()
class PostSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Post
a minimal REST API
views.py
class PostViewSet(viewsets.ModelViewSet):
queryset = Post.objects.all()
serializer_class = PostSerializer
a minimal REST API
urls.py
router = routers.SimpleRouter()
router.register(r'posts', views.PostViewSet)
urlpatterns = patterns('',
url(r'^', include(router.urls)),
….
a minimal REST API
This project can be found at:
https://github.com/zheli/django-rest-kog
tag: v1
Key elements
serializer
views
serializer
serializing:
querysets, model instances->python native
datatypes
deserializing:
data string->model instances
serializer
automatic serializers from model:
ModelSerializer, HyperlinkedModelSerializer
views
automatic views from model:
ModelViewSets: CRUD + list
ReadOnlyModelViewSet: retrieve + list
test
APIRequestFactory() from RequestFactory
APIClient() from Client
Test POST request:
class PostTests(APITestCase): ←- self.client == APIClient()
def test_create_post(self):
response = self.client.post(‘/posts/’, {‘post’: ‘this is a test post’}, format=’json’)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
assert response.data is not None
documentation
Django REST Swagger
documentation
documentation
REST Framework Docs
documentation
Questions & Feedbacks
Interesting?
What’s next?

More Related Content

PPTX
Introduction to Django Rest Framework
PDF
Django Rest Framework - Building a Web API
PDF
Angular
PPTX
Intro to React
PDF
Introduction to back-end
PDF
Angular Directives
PPTX
Angular Directives
Introduction to Django Rest Framework
Django Rest Framework - Building a Web API
Angular
Intro to React
Introduction to back-end
Angular Directives
Angular Directives

What's hot (20)

PPTX
Spring boot Introduction
PPTX
Introduction to angular with a simple but complete project
PDF
Introduction to ASP.NET Core
PPTX
PDF
Building an API with Django and Django REST Framework
PPTX
Angularjs PPT
PDF
Django Introduction & Tutorial
PDF
Spring MVC Framework
PDF
Angular 16 – the rise of Signals
PPT
Introduction To Django
PPT
Asp.net.
PPTX
Angular 9
PPTX
Getting Started with React.js
PPTX
Introduction to Django
PPT
Angular 8
PPTX
Introduction to mvc architecture
PPTX
Ef code first
PPTX
Angular introduction students
PDF
Python Django tutorial | Getting Started With Django | Web Development With D...
Spring boot Introduction
Introduction to angular with a simple but complete project
Introduction to ASP.NET Core
Building an API with Django and Django REST Framework
Angularjs PPT
Django Introduction & Tutorial
Spring MVC Framework
Angular 16 – the rise of Signals
Introduction To Django
Asp.net.
Angular 9
Getting Started with React.js
Introduction to Django
Angular 8
Introduction to mvc architecture
Ef code first
Angular introduction students
Python Django tutorial | Getting Started With Django | Web Development With D...
Ad

Viewers also liked (16)

PDF
Django REST Framework
PPTX
REST Easy with Django-Rest-Framework
PPTX
Implementation of RSA Algorithm for Speech Data Encryption and Decryption
PDF
Django rest framework tips and tricks
KEY
Web application development with Django framework
ODP
* DJANGO - The Python Framework - Low Kian Seong, Developer
PDF
A gentle intro to the Django Framework
PPT
Django orm-tips
PPTX
Django Framework Overview forNon-Python Developers
PPTX
Basic Django ORM
PDF
DJANGO-REST-FRAMEWORK: AWESOME WEB-BROWSABLE WEB APIS
PDF
Django ORM
KEY
Advanced Django ORM techniques
PPTX
Swagger - make your API accessible
PDF
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
PDF
Create responsive websites with Django, REST and AngularJS
Django REST Framework
REST Easy with Django-Rest-Framework
Implementation of RSA Algorithm for Speech Data Encryption and Decryption
Django rest framework tips and tricks
Web application development with Django framework
* DJANGO - The Python Framework - Low Kian Seong, Developer
A gentle intro to the Django Framework
Django orm-tips
Django Framework Overview forNon-Python Developers
Basic Django ORM
DJANGO-REST-FRAMEWORK: AWESOME WEB-BROWSABLE WEB APIS
Django ORM
Advanced Django ORM techniques
Swagger - make your API accessible
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
Create responsive websites with Django, REST and AngularJS
Ad

Similar to Introduction to Django REST Framework, an easy way to build REST framework in Django (20)

PPTX
PPTX
Write an API for Almost Anything: The Amazing Power and Flexibility of Django...
PDF
Django Rest Framework + React
PDF
DRF React
PPTX
Write an API for Almost Anything: The Amazing Power and Flexibility of Django...
PPTX
Django rest framework
PDF
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
PDF
Django Rest Framework - tips & trick
PDF
Rest api with Python
PDF
Rest apis with DRF
PPTX
Django with REST API Online Training - NareshIT
PDF
Django Restful Web Services Gaston C Hillar
PDF
Free django
PPTX
React django
PDF
Easy Step-by-Step Guide to Develop REST APIs with Django REST Framework
PPTX
Django REST Framework 2022fffffffff.pptx
PDF
How to Implement Token Authentication Using the Django REST Framework
PDF
Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...
PDF
Building RESTful APIs
KEY
Jumpstart Django
Write an API for Almost Anything: The Amazing Power and Flexibility of Django...
Django Rest Framework + React
DRF React
Write an API for Almost Anything: The Amazing Power and Flexibility of Django...
Django rest framework
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
Django Rest Framework - tips & trick
Rest api with Python
Rest apis with DRF
Django with REST API Online Training - NareshIT
Django Restful Web Services Gaston C Hillar
Free django
React django
Easy Step-by-Step Guide to Develop REST APIs with Django REST Framework
Django REST Framework 2022fffffffff.pptx
How to Implement Token Authentication Using the Django REST Framework
Django Rest Framework | How to Create a RESTful API Using Django | Django Tut...
Building RESTful APIs
Jumpstart Django

Recently uploaded (20)

PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Cost to Outsource Software Development in 2025
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Nekopoi APK 2025 free lastest update
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Transform Your Business with a Software ERP System
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
assetexplorer- product-overview - presentation
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Which alternative to Crystal Reports is best for small or large businesses.pdf
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Operating system designcfffgfgggggggvggggggggg
Odoo Companies in India – Driving Business Transformation.pdf
Upgrade and Innovation Strategies for SAP ERP Customers
Softaken Excel to vCard Converter Software.pdf
Cost to Outsource Software Development in 2025
Design an Analysis of Algorithms II-SECS-1021-03
Nekopoi APK 2025 free lastest update
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
How to Choose the Right IT Partner for Your Business in Malaysia
Transform Your Business with a Software ERP System
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
L1 - Introduction to python Backend.pptx
Reimagine Home Health with the Power of Agentic AI​
Understanding Forklifts - TECH EHS Solution
assetexplorer- product-overview - presentation
Why Generative AI is the Future of Content, Code & Creativity?
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises

Introduction to Django REST Framework, an easy way to build REST framework in Django