Click to jump to the REST-Framework column directory

The framework provides very standard attributes for request and extends the standard HTTPRequest object so that you can easily use it in your development.

.data

In Request.data you can easily retrieve json data or form submissions sent to you by the client, without the hassle of request.post.get (), and parse file transfers.

def update(self, request, *args, **kwargs) :
    if request.data.get('params') = =True:...Copy the code

.query_params

Request.query_params.get (‘params’) is equivalent to request.get.GET (‘params’).

.user

If you are authenticated, accessing this property gives you an instance object of your user model. You can get the user ID property from request.user.id, but without authentication, Or not verified under the condition of this property returns the django. Contrib. Auth. Models. AnonymousUser instances of an object.

.auth

This property returns an instance of the authenticating user’s token if the authentication is successful, or None otherwise, depending on the authentication policy.

.method

This property returns the requested uppercase string, such as GET.

These attributes are generally not used in requests that do not override the framework’s methods or implement custom return data, validation, and so on.