[Fixed]-Example when request.POST contain query string in django

44👍

If your request is post:

request.method == ‘POST’

but the requested url contains a query string. e.g:

/your-url?param1=value-one

you can still take POST parameters through:

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

and query string parameters through:

request.GET.get("param1")

althrough, you pick up all parameters at once (POST and GET), through REQUEST:

request.REQUEST[‘param1’] # comes from query string

request.REQUEST[‘my-field’] # comes from request BODY (POST)

Leave a comment