Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Some things to know about Django Rest Framework
Search
Ordoquy Xavier - Linovia
December 12, 2013
Programming
250
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Some things to know about Django Rest Framework
Ordoquy Xavier - Linovia
December 12, 2013
Transcript
16 slides
Django Rest Framework Tips and Tricks Xavier ORDOQUY @linovia_net
Freelance! (since 2004) Python Django! (Backend) Raven maintainer! (Sentry client)
Former! PyGTK! contributor Various! pull requests irc: Linovia @linovia_net Expertise Dev
Reminder • It is Django ! ! • It is
Python !
Fully featured • Serializers • ModelSerializers • Parsers • Renderers
• Authentication • Permission • Throttling • Routers • Views • ViewSets • Filtering • Testing • Pagination
from rest_framework.decorators import api_view! ! @api_view(['GET'])! def hello_world(request):! return Response({"message":
"Hello, world!"}) but loosely coupled Authentication Content negotiation Serializers Generic views
Customizable web interface
Debug toolbar
pre/post save class MyCreateView(CreateAPIView):! model = models.MyModel! serializer_class = serializers.MySerializer!
! def post_save(self, obj, created):! if created:! obj.reviewers = [user1, user2]!
Class based views class MyMixin(object):! model = models.MyModel! serializer_class =
serializers.MySerializer! ! ! class MyCreateView(MyMixin, CreateAPIView):! pass! • MRO: mixins are on the left side
# views.py! class UserViewSet(viewsets.ModelViewSet):! queryset = User.objects.all()! serializer_class = UserSerializer!
! # urls.py! router = DefaultRouter()! router.register(r'users', views.UserViewSet)! ! urlpatterns = patterns('',! url(r'^', include(router.urls)),! )! Viewsets & routers Nice to get started but optional
Auth / Permissions • Auth are for knowing who you
are ! • Permissions are to grant you access
Testing Utilities • APIRequestFactory + format ! • force_authenticate •
APIClient response = self.client.get('/users/4/')! self.assertEqual(response.data,! {'id': 4, 'username': 'lauren'})!
Performances • Fast to prototype • Easy to tune •
Django performance tips also applies !
Temps em ms 0 10 20 30 40 50 60
70 80 90 100 110 120 130 140 Full stack Serialisation Redis Content nego Middleware HttpResponse Database lookup Redis lookup Serialization Django request/response API view Response rendering
None
• Django Rest Framwork Optimization: http://dabapps.com/blog/api-performance-profiling-django-rest-framework/
More Decks by Ordoquy Xavier - Linovia
See All by Ordoquy Xavier - Linovia
Comprendre les interruptions de service lors des mises en production.
xordoquy
0
20
SQLAlchemy - un ami qui vous veut du bien
xordoquy
0
31
pycon.fr 2018 - Django REST framework workshop
xordoquy
0
360
mauvaises bonnes idées pour REST
xordoquy
1
420
Authentication and Permissions with Django REST framework
xordoquy
0
210
Buildbot 0.9
xordoquy
0
110
Performances Django REST framework - DjangoCong 2016
xordoquy
0
140
Présentation de l'architecture REST - meetup Django Paris
xordoquy
0
120
Django REST framework workshop @Djangocon Europe 2015
xordoquy
0
130
Other Decks in Programming
See All in Programming
Goコンパイラを作ってGoをもっと理解する / Build a Go compiler to better understand Go
ikura_hamu
0
130
SFCで実現する病院・医療システムの動的組み立て式UI
koukimiura
1
180
AIがコードを書いてくれる時代、我々は何を確かめるのか
yosuke_furukawa
PRO
13
5.9k
Railsのためのパスキー実践入門 〜マルチテナントSaaSでの意思決定〜
utakaha
4
4.3k
React Native経験者が Flutterを30⽇間触って驚いたこと
3saito
0
180
Performance Optimization With LLMs
xleitix
0
260
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
170
私なりのハーネスエンジニアリング ~独自の言語処理系の開発を通して~
seosoft
0
200
Vapor Mode でアクセシビリティは 壊れないか検証した話
fuqda
1
350
GraphQL の onError と Nullability のこれから
quramy
0
220
LLM 101
dalinaum
0
490
AI時代のIaC入門 〜なぜインフラをコードで管理したいのか?〜 / Introduction to IaC in the AI Era
akihisaikeda
6
1.5k
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
How to build a perfect <img>
jonoalderson
1
6.2k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
580
Unsuck your backbone
ammeep
672
58k
Embracing the Ebb and Flow
colly
88
5.2k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7.1k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
2
520
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
48k
Deep Space Network (abreviated)
tonyrice
0
410
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1.1k