V
V
Vampre2019-07-23 14:52:39
Django
Vampre, 2019-07-23 14:52:39

What is the difference between request.body and request.POST?

I send data from the frontend:

const res = await fetch('/pushes/save_information', {
        method: 'POST',
        body: JSON.stringify(data),
        headers: {
            'content-type': 'application/json'
        },
        credentials: "include"
    });

In this case, the data is in request.body, and request.POST is empty. POST only stores data in forms format?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SagePtr, 2019-07-23
@Vampre

request.body contains the raw request body.
request.POST - parsed if the Content-Type of the request is multipart/form-data or application/x-www-form-urlencoded

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question