Analysis drf request module

A, drf request module

  1. , Drf the request is encapsulated again in the request on the basis of wsgi

  2. , Wsgi the request as a request drf of property: _request

  3. The new request for the old request made fully compatible

  4. The new request for more standardized data analysis:

    All the stitching parameters are parsed into query_params in

    All data packets are parsed into data in

    query_params and data belonging QueryDict type, .dict () is converted into a native type dict

Source code analysis

1, drf of APIView categories: Rewrite the as_view (), and he also inherited the View class, the main logic still call the parent View of as_view ().

2.as_view (), a local disabled csrf certification focus: all inherited drf base view class APIView view class, not doing csrf certified check

3.drf of APIView class: override the dispatch (), on the second request was encapsulated inside: self.initialize_request (request, * args, ** kwargs)

  1. Inner core:

Request initialization method to go drf the __init __: self._request = request

Request of the getter method drf __getattr__: request start self._request take reflection properties, and then did not get to take in drf

5. Core: request access to all of the content in addition to the original request wsgi protocol, can access query_params, data, encapsulates it the properties of these two methods

Guess you like

Origin www.cnblogs.com/guapitomjoy/p/11892257.html