17 January 2019

Django REST Framework Abstraction Grid

Django REST Framework

The Django Rest Framework (DRF) is the leading REST API library for Django projects. It has fantastic and comprehensive documentation, much like the Django project. However, with all the classes, mixins, and other options it provides, the abstractions can get a bit confusing.

Whenever I use a library I like to have a clear picture of its main concepts and how the pieces fit together, so I ended up plotting this out for the DRF to show how the URLs, REST operations, and CRUD layer all fit together to make an API. This is intended for someone who has read over the DRF documentation and feels like they kind of get it, but starts to feel lost in all the different layers of abstraction.

Behold, the Django REST Framework - Abstraction Grid:

Django REST Framework Abstraction Grid

(click to view full size: svg | pdf | png)

The big things to see here are:

  1. You are expected to follow their mostly flat structure of "/{your_objects}" or "/{your_objects}/{pk}" and to apply the various HTTP methods as shown—if you fight this structure, you will have a bad time
  2. The Generics are all doing the REST operation work (connecting to a URL and HTTP method)
  3. The Mixins are all doing the CRUD operations (connecting into the DB with your model)
  4. See if you can use GenericViews Combos or better the ViewSets
  5. This doesn’t include serializers, sorry!

If some of this is outdated, let me know! I have it in a sketch file that is easy to update.




Interested in working with me at Superset to help shape the future of virtual fitness and to empower people to launch their own businesses online? We’re hiring a full-stack engineer. 💪🤓💻 Apply online



Did you find this helpful or fun? paypal.me/mrcoles
comments powered by Disqus

Peter Coles

Peter Coles

is a software engineer living in NYC who is building Superset 💪 and also created GoFullPage 📸
more »

github · soundcloud · @lethys · rss