API, Request object and Response object

   API application programming interface, also known as application programming ② (interface)

It is the code provided by the computer operating system or the program library to the application program for calling, which is the convention of the connection between the different components of the ① (software) system

 

Detailed concept explanation: ①Simply put, software is a collection of programs and documents. Software includes all programs running on the computer, regardless of its architecture. For example, executable files, libraries and scripting languages ​​belong to software.

② In object-oriented programming, an interface is usually defined as a collection of methods. Access to properties of an object is usually done through property access functions

 

Request and Response (request and response)

When a page is requested, Django creates an HttpRequest object that contains the request metadata. When Django loads the corresponding view, the HttpRequest object will be used as the first parameter of the view function. Each view will return an HttpResponse object.

For example in cart item view views:

def render_add(request):
    if request.method == 'POST':
        prodect_id = request.POST['id']
        posts = ItemModel.objects.filter(id=prodect_id)
        return HttpResponse(posts)

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326777426&siteId=291194637