Demystifying the Django REST Framework

Haris Ibrahim K V

Sunday 1:30 p.m.–5 p.m.
Audience level: Intermediate or Advanced

Description

The tutorial covers the basics of Django REST Framework, building of RESTful apis from DRF's perspective and a hands on approach all along while we learn together.

Abstract

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.


Buy your conference and tutorial tickets here! Tutorials are $150 per session.