From ed93e13a1c6f792e14176bdaa5e96d0fa2c63a2f Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 1 Dec 2014 12:20:07 +0000 Subject: Update documentation --- api-guide/requests/index.html | 45 +++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'api-guide/requests/index.html') diff --git a/api-guide/requests/index.html b/api-guide/requests/index.html index a074e516..11781510 100644 --- a/api-guide/requests/index.html +++ b/api-guide/requests/index.html @@ -164,6 +164,10 @@ Serializer relations +
  • + Validators +
  • +
  • Authentication
  • @@ -263,6 +267,10 @@ 2.4 Announcement +
  • + 3.0 Announcement +
  • +
  • Kickstarter Announcement
  • @@ -350,15 +358,19 @@
  • - .DATA + .data
  • - .FILES + .query_params
  • - .QUERY_PARAMS + .DATA and .FILES +
  • + +
  • + .QUERY_PARAMS
  • @@ -448,7 +460,10 @@ -

    Requests

    +
    +

    Note: This is the documentation for the version 3.0 of REST framework. Documentation for version 2.4 is also available.

    +
    +

    Requests

    If you're doing REST-based web service stuff ... you should ignore request.POST.

    — Malcom Tredinnick, Django developers group

    @@ -457,24 +472,26 @@

    Request parsing

    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

    -

    request.DATA returns the parsed content of the request body. This is similar to the standard request.POST attribute except that:

    +

    .data

    +

    request.data returns the parsed content of the request body. This is similar to the standard request.POST and request.FILES attributes except that:

    For more details see the parsers documentation.

    -

    .FILES

    -

    request.FILES returns any uploaded files that may be present in the content of the request body. This is the same as the standard HttpRequest behavior, except that the same flexible request parsing is used for request.DATA.

    -

    For more details see the parsers documentation.

    -

    .QUERY_PARAMS

    -

    request.QUERY_PARAMS is a more correctly named synonym for request.GET.

    -

    For clarity inside your code, we recommend using request.QUERY_PARAMS instead of the usual request.GET, as any HTTP method type may include query parameters.

    +

    .query_params

    +

    request.query_params is a more correctly named synonym for request.GET.

    +

    For clarity inside your code, we recommend using request.query_params instead of the Django's standard request.GET. Doing so will help keep your codebase more correct and obvious - any HTTP method type may include query parameters, not just GET requests.

    +

    .DATA and .FILES

    +

    The old-style version 2.x request.data and request.FILES attributes are still available, but are now pending deprecation in favor of the unified request.data attribute.

    +

    .QUERY_PARAMS

    +

    The old-style version 2.x request.QUERY_PARAMS attribute is still available, but is now pending deprecation in favor of the more pythonic request.query_params.

    .parsers

    The APIView class or @api_view 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.

    You won't typically need to access this property.


    -

    Note: If a client sends malformed content, then accessing request.DATA or request.FILES may raise a ParseError. By default REST framework's APIView class or @api_view 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. By default REST framework's APIView class or @api_view decorator will catch the error and return a 400 Bad Request response.

    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.


    Content negotiation

    @@ -537,7 +554,7 @@ -- cgit v1.2.3