Demystifying the Django REST Framework
Haris Ibrahim K. V. (~harisibrahimkv) |
This will be an intermediate tutorial on Django REST Framework. For a first time user, DRF presents a ton of magic. Things work, but you end up not knowing or understanding what is happening behind the scenes. If you would want to tweak something, you wouldn't know where to start or what to look at.
I've had quite a few frustrating moments trying to figure out what method mapped to which action, and which ones to override when. The fact that DRF does not impose the REST architecture confused me to a good extent as well. Nested relationships was another beast which was hard to tame.
This tutorial will build an app - not a full fledged front end design but the endpoints that are required, and will showcase implementing endpoints using complete abstraction that DRF provides including Routers, ViewSets and builtin Serializers as the first step.
The second step will break the ViewSets and implement them as normal class based views, showing what happens behind the scenes. How the method are mapped, how it flows through from the moment a request hits one of the views.
The third step will involve writing the routers by hand, using normal views and how to fine tune serializers to add your custom fields, etc.
Participants should have prior experience using Django. Having completed the official tutorial on the Django website should be good enough.
Former Geek herder @HasGeek. Used to be Python tamer @Eventifier and now @aksharadotorg. An amateur writer. A 'psycho' path author. Husband. One of the organizers of PyCon India for the last two years and recently a DjangoGirls coach.
Presented on Django / Redis at PyCon 2014 Singapore, Ireland and Poland.