April 7, 2017 @ 9:30 a.m.

Demystifying the Django REST Framework.

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 methods 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.

We'll use DRF 3.x for the workshop. Detailed setup instructions will be sent to you well before the workshop.

The rough plan is:

0 - 20 minutes: Brushing up REST architecture and general ice breaker.

20 - 50 minutes: Setting up a Django project and DRF installation.

50 - 1h 20: Implementing the first endpoint, with all abstraction and goodness of DRF.

1h 20 - 1h 40: Breaking down the ViewSet into simple APIViews and explaining the methods.

1h 40 - 2h 00: Breaking it further down to manually writing the routers, normal views, etc.

2h 00 - 2h 30: Implementation of a nested relationship.

2h 30 - 3h 00: General discussion, pitfalls and do's as well as dont's.