Please post example code when request.POST contain query string in django, because i think my django version is bugged.
EDIT:
You simple can't, query string is always in GET, and this was my problem.
A POST request can include a query string, however normally it doesn't - a standard HTML form with a POST action will not normally include a query string for example.
POST should not have query param. You can implement the service to honor the query param, but this is against REST spec. "Why do you pass it in a query param?" Because, like for GET requests, the query parameters are used to refer to an existing resource.
A query string commonly includes fields added to a base URL by a Web browser or other client application, for example as part of an HTML, choosing the appearance of a page, or jumping to positions in multimedia content.
Django runs through each URL pattern, in order, and stops at the first one that matches the requested URL, matching against path_info . Once one of the URL patterns matches, Django imports and calls the given view, which is a Python function (or a class-based view).
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With