Response generators methods naming - Deepstash
Machine Learning With Google

Learn more about computerscience with this collection

Understanding machine learning models

Improving data analysis and decision-making

How Google uses logic in machine learning

Machine Learning With Google

Discover 95 similar ideas in

It takes just

14 mins to read

Response generators methods naming

The response is generated using the specific class method of the resource. If it's a default endpoint, the methods look like [HTTP_method]_[view_type] (e.g. get_list, post_detail) and if it's a custom endpoint, the method's name is the defined route for the endpoint (e.g. add_more_entries)

1

12 reads

MORE IDEAS ON THIS

Endpoint function structure

Each endpoint needs a function to manipulate and return the data. But these functions have a standard format

  • They have as parameters `self` (being a class method inside the resource), `request` (which is the `Request` instance of the client's API call
  • They expect the returned v...

1

13 reads

Resource.dispatch method

The dispatch method makes sure the followings are fulfilled:

  • the HTTP Method inside the request is allowed in the resource
  • the resource has a method that can handle the request (e.g. get_list, get_detail, get_custom_endpoint)
  • the user is authenticated
  • the user d...

1

11 reads

Types of endpoints

In Tastypie, there are 3 types of endpoints:

  1. list
  2. detail
  3. custom

List endpoints return a list of objects (as the name implies) and it looks like `host_address/api/entity`. 

Detail endpoints return a single instance of an object and it looks similar to t...

1

12 reads

Generating the response for `get_list`

The following actions will be done when calling the get_list:

  1. All the available objects are fetched via `Resource.obj_get_list`
  2. Objects are sorted via `Resource.apply_sorting` and paginated with the built-in Paginator
  3. the data will be dehydrated, meaning Tastypie will k...

1

11 reads

What is Tastypie

Tastypie is a  framework for Django that helps programmers to develop RESTful APIs on top of their already existing projects.

1

19 reads

Once the Tastypie returned the HttpResponse object, Django will send it to the client which made the request.

As a conclusion, you can consider Tastypie endpoints some Django views which return processed data in standardized formats (or HTTP errors, based on the case).

1

10 reads

Introduction

This article is recommended to be read having some prerequisites. You should be familiar with HTTP Methods and some basics regarding Django.

If that's not your case, please check the resources below before proceeding with the article:

1

33 reads

Handling a request inside Tastypie

Once Django redirects the request to a Tastypie resource, it checks for the available URLs and lets Tastypie do the rest.  

Assuming the URL is`host-domain/api/v1/entity/` (which is a list view):

If the view was matched, `Resource.wrap_view('dispatch_list')` is called. The wrap_view m...

1

8 reads

Routing a request

Now let's focus on what's the steps for a request to be fulfilled on a Tastypie endpoint.

When a request is received from a client, Django checks for any existing routes inside `urlpatterns`, the variable with all the available routes inside the project.

If a pattern was found, Django...

1

6 reads

What is a Tastypie Resource

As a general rule, each group of endpoints is seen as a resource. When I say a group of endpoints I mean a collection of HTTP methods on a specific route (e.g. GET, POST and DELETE on /api/entity).

These resources have a lot of features, which include allowing you to access the end...

1

14 reads

CURATED FROM

IDEAS CURATED BY

teni

Normal person with peculiar dreams @unkl's protégé @cristianmezei's disciple

My takes after reading the Tastypie documentation, regarding how a request is handled inside an endpoint

Related collections

Other curated ideas on this topic:

Naming

Begin by considering what kind of name you want. Descriptive names do just that: describe. Suggestive names, like CRACK + CIDER, use metaphors or association to hint at what the project is doing. They’re also the most common type of name because they’re unique and functional while also being crea...

Qualitative and Quantitative as complementary methods

Qualitative and Quantitative as complementary methods

Qualitative and quantitative methods can be complementary (also known as mixed-method). Sometimes we use them together, especially in public health.

We want to use tools that are well-suited to the research questions, and build on the strengths of each met...

Experiment With Various Meditation Methods

For the first few weeks, practice your chosen method every day. After a while, you can also branch out towards some other method, like a guided meditation or some guidance from a book or article you see.

This exploration expands your repertoire of methods, expanding your understa...

Read & Learn

20x Faster

without
deepstash

with
deepstash

with

deepstash

Personalized microlearning

100+ Learning Journeys

Access to 200,000+ ideas

Access to the mobile app

Unlimited idea saving

Unlimited history

Unlimited listening to ideas

Downloading & offline access

Supercharge your mind with one idea per day

Enter your email and spend 1 minute every day to learn something new.

Email

I agree to receive email updates