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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
1
2k
AIが生成したコードは読むべきか?抽象化設計とコードの品質保証 / abstraction-design-and-quality
minodriven
16
9.1k
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
2.4k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
310
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
380
複数ドメインを一つのアプリに統合するFlutterの設計と運用_FlutterKaigi2026登壇資料(須永高弘)
takahirosunaga
0
180
우리의 Nitro Modules는 당신의 Turbo Modules보다 아름답다
l2hyunwoo
0
260
AI-Powered Domain-Driven Design
ziobrando
0
450
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
170
コード生成時代のAPI定義を支えるRequest Spec移行
pvcresin
0
110
Modernizing iOS Apps
seyfoyun
0
150
仕様駆動開発入門 (何を作るかを先に決めて渡す) | 目指せ Kiro マスター 05
inariku
PRO
2
150
Featured
See All Featured
Believing is Seeing
oripsolob
1
280
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
530
SEO for Brand Visibility & Recognition
aleyda
0
4.9k
AI: The stuff that nobody shows you
jnunemaker
PRO
12
1.3k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.6k
Abbi's Birthday
coloredviolet
5
11k
Crafting Experiences
bethany
1
440
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Faster Mobile Websites
deanohume
310
32k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
2
520