Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
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
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
More Decks by Ordoquy Xavier - Linovia
See All by Ordoquy Xavier - Linovia
SQLAlchemy - un ami qui vous veut du bien
xordoquy
0
25
pycon.fr 2018 - Django REST framework workshop
xordoquy
0
360
mauvaises bonnes idées pour REST
xordoquy
1
410
Authentication and Permissions with Django REST framework
xordoquy
0
200
Buildbot 0.9
xordoquy
0
110
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
130
Django REST framework - DjangoConG 2015
xordoquy
3
150
Other Decks in Programming
See All in Programming
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
150
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
450
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
220
為什麼你並不需要ViewModel / No, you don't need a ViewModel
lovee
1
500
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
930
テーブルをDELETEした
yuzneri
0
140
人間の目はかわらない、だからJPEGは30年もつ
yuzneri
12
18k
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
320
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
3
510
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
380
php-fpmのプロセスが枯渇した日-調査・対処・そして本当にやるべきだったこと-
shibuchaaaan
0
290
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
330
Featured
See All Featured
Chasing Engaging Ingredients in Design
codingconduct
0
270
Automating Front-end Workflow
addyosmani
1369
210k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
Become a Pro
speakerdeck
PRO
31
6.2k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.3k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
340
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Ruling the World: When Life Gets Gamed
codingconduct
0
300
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
Six Lessons from altMBA
skipperchong
29
4.4k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
570
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/