Call Diagram of Django Tastypie Resource get_list method

Tastypie is a Django-based framework for building a REST API. It is most effective as a direct wrapper on Django models, resulting in extremely concise code to expose models as REST resources (using the now-standard terminology where resource means a collection of similar objects). This broad overview can be diagramed something like the following.

Tastypie Overview

But Tastypie is applicable even for more complex REST API designs, using non-Django data sources, or doing elaborate things to the Django models before sending them back to the client.

These many extension points are provided as methods to override in the tastypie.resources.Resource class. There are enough similarly named methods (get_list, obj_get_list, get_object_list, …) that you may have a hard time figuring out where you need to plug in, like these folks:

Well, I have drawn a picture of the call stack for the get_list method. In the following, I note which methods have access to the HTTP Request (turns out it is all of them, basically) and which have access to the working copy of the objects (or Django query result) to be returned to the client. I hope you find this helpful, and please comment with any corrections.

Tastypie get_object call diagram
Tagged , , ,

3 thoughts on “Call Diagram of Django Tastypie Resource get_list method

  1. huntme says:

    can you please explain the difference between get_object_list and obj_get_list

    • Kenn Knowles (@KennKnowles) says:

      Yes. obj_get_list is the main entry point for the API and includes all filter processing and access control. get_object_list is a lower-level function that just clones the queryset by default.

  2. roger says:

    That’s quite good. Did you try manytomany through join table in tastypie? I am struggling with a problem in this question for weeks

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: