Example when request.POST contains a query string in django

Please send the sample code when request.POST contains the query string in django, because I think my version of django is listening.

EDIT:

You just can't, the query string is always in GET, and that was my problem.

+4
source share
1 answer

If your request is sent:

request.method == 'POST'

but the requested url contains the query string. eg:

/your address? Param1 = value-one

You can accept POST parameters through:

request.POST.get ("my-field", None)

and query string parameters with:

request.GET.get ("param1")

althrough, you immediately get all the parameters (POST and GET), through REQUEST:

request.REQUEST ['param1'] # appears from the query string

request.REQUEST ['my-field'] # comes from a BODY request (POST)

+20
source

Source: https://habr.com/ru/post/1311666/


All Articles