
If a client sends a request with a content-type that cannot be parsed then a UnsupportedMediaType exception will be raised, which by default will be caught and return a 415 Unsupported Media Type response. By default REST framework's APIView class or decorator will catch the error and return a 400 Bad Request response. Note: If a client sends malformed content, then accessing request.data may raise a ParseError. You won't typically need to access this property. The APIView class or decorator will ensure that this property is automatically set to a list of Parser instances, based on the parser_classes set on the view or based on the DEFAULT_PARSER_CLASSES setting. Doing so will help keep your codebase more correct and obvious - any HTTP method type may include query parameters, not just GET requests.parsers

Request.query_params is a more correctly named synonym for request.GET.įor clarity inside your code, we recommend using request.query_params instead of the Django's standard request.GET. For example you can handle incoming JSON data similarly to how you handle incoming form data.įor more details see the parsers documentation.query_params It supports REST framework's flexible request parsing, rather than just supporting form data.
SETS THEM APART FROM THE REST SYNONYM PATCH
It supports parsing the content of HTTP methods other than POST, meaning that you can access the content of PUT and PATCH requests.It includes all parsed content, including file and non-file inputs.This is similar to the standard request.POST and request.FILES attributes except that: Request.data returns the parsed content of the request body.

REST framework's Request objects provide flexible request parsing that allows you to treat requests with JSON data or other media types in the same way that you would normally deal with form data.data REST framework's Request class extends the standard HttpRequest, adding support for REST framework's flexible request parsing and request authentication. Malcom Tredinnick, Django developers group If you're doing REST-based web service stuff.
