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 +
Note: This is the documentation for the version 3.0 of REST framework. Documentation for version 2.4 is also available.
+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.DATAreturns the parsed content of the request body. This is similar to the standardrequest.POSTattribute except that:.data
+
request.datareturns the parsed content of the request body. This is similar to the standardrequest.POSTandrequest.FILESattributes except that:+
- It includes all parsed content, including file and non-file inputs.
- It supports parsing the content of HTTP methods other than
POST, meaning that you can access the content ofPUTandPATCHrequests.- It supports REST framework's flexible request parsing, rather than just supporting form data. For example you can handle incoming JSON data in the same way that you handle incoming form data.
For more details see the parsers documentation.
-.FILES
--
request.FILESreturns any uploaded files that may be present in the content of the request body. This is the same as the standardHttpRequestbehavior, except that the same flexible request parsing is used forrequest.DATA.For more details see the parsers documentation.
-.QUERY_PARAMS
--
request.QUERY_PARAMSis a more correctly named synonym forrequest.GET.For clarity inside your code, we recommend using
+request.QUERY_PARAMSinstead of the usualrequest.GET, as any HTTP method type may include query parameters..query_params
++
request.query_paramsis a more correctly named synonym forrequest.GET.For clarity inside your code, we recommend using
+request.query_paramsinstead of the Django's standardrequest.GET. Doing so will help keep your codebase more correct and obvious - any HTTP method type may include query parameters, not justGETrequests..DATA and .FILES
+The old-style version 2.x
+request.dataandrequest.FILESattributes are still available, but are now pending deprecation in favor of the unifiedrequest.dataattribute..QUERY_PARAMS
+The old-style version 2.x
request.QUERY_PARAMSattribute is still available, but is now pending deprecation in favor of the more pythonicrequest.query_params..parsers
The
APIViewclass or@api_viewdecorator will ensure that this property is automatically set to a list ofParserinstances, based on theparser_classesset on the view or based on theDEFAULT_PARSER_CLASSESsetting.You won't typically need to access this property.
-Note: If a client sends malformed content, then accessing
+request.DATAorrequest.FILESmay raise aParseError. By default REST framework'sAPIViewclass or@api_viewdecorator will catch the error and return a400 Bad Requestresponse.Note: If a client sends malformed content, then accessing
request.datamay raise aParseError. By default REST framework'sAPIViewclass or@api_viewdecorator will catch the error and return a400 Bad Requestresponse.If a client sends a request with a content-type that cannot be parsed then a
UnsupportedMediaTypeexception will be raised, which by default will be caught and return a415 Unsupported Media Typeresponse.
Content negotiation
@@ -537,7 +554,7 @@ -- cgit v1.2.3