Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Some things to know about Django Rest Framework
Search
Ordoquy Xavier - Linovia
December 12, 2013
Programming
1
240
Some things to know about Django Rest Framework
Ordoquy Xavier - Linovia
December 12, 2013
Tweet
Share
More Decks by Ordoquy Xavier - Linovia
See All by Ordoquy Xavier - Linovia
SQLAlchemy - un ami qui vous veut du bien
xordoquy
0
6
pycon.fr 2018 - Django REST framework workshop
xordoquy
0
330
mauvaises bonnes idées pour REST
xordoquy
1
380
Authentication and Permissions with Django REST framework
xordoquy
0
190
Buildbot 0.9
xordoquy
0
100
Performances Django REST framework - DjangoCong 2016
xordoquy
0
130
Présentation de l'architecture REST - meetup Django Paris
xordoquy
0
110
Django REST framework workshop @Djangocon Europe 2015
xordoquy
0
120
Django REST framework - DjangoConG 2015
xordoquy
3
140
Other Decks in Programming
See All in Programming
大体よく分かるscala.collection.immutable.HashMap ~ Compressed Hash-Array Mapped Prefix-tree (CHAMP) ~
matsu_chara
2
220
エディターってAIで操作できるんだぜ
kis9a
0
730
まだ間に合う!Claude Code元年をふりかえる
nogu66
5
840
新卒エンジニアのプルリクエスト with AI駆動
fukunaga2025
0
230
複数人でのCLI/Infrastructure as Codeの暮らしを良くする
shmokmt
5
2.3k
Tinkerbellから学ぶ、Podで DHCPをリッスンする手法
tomokon
0
130
ViewファーストなRailsアプリ開発のたのしさ
sugiwe
0
480
C-Shared Buildで突破するAI Agent バックテストの壁
po3rin
0
390
Microservices rules: What good looks like
cer
PRO
0
1.5k
バックエンドエンジニアによる Amebaブログ K8s 基盤への CronJobの導入・運用経験
sunabig
0
160
dotfiles 式年遷宮 令和最新版
masawada
1
780
【CA.ai #3】ワークフローから見直すAIエージェント — 必要な場面と“選ばない”判断
satoaoaka
0
250
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
4 Signs Your Business is Dying
shpigford
186
22k
It's Worth the Effort
3n
187
29k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
How STYLIGHT went responsive
nonsquared
100
6k
Building an army of robots
kneath
306
46k
How to train your dragon (web standard)
notwaldorf
97
6.4k
Visualization
eitanlees
150
16k
Designing Experiences People Love
moore
143
24k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
Fireside Chat
paigeccino
41
3.7k
Mobile First: as difficult as doing things right
swwweet
225
10k
Transcript
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/