diff options
| author | Tom Christie | 2012-10-14 20:46:38 +0100 |
|---|---|---|
| committer | Tom Christie | 2012-10-14 20:46:38 +0100 |
| commit | 7a89d7a770d310f8b72178c561fcd04e6c15e5c4 (patch) | |
| tree | 95de410fe20832c0993ac4b8b6c4e08ed0b8c0e4 /docs/api-guide | |
| parent | b3477b3b6c1431a03089d68828c13568d02dc990 (diff) | |
| download | django-rest-framework-7a89d7a770d310f8b72178c561fcd04e6c15e5c4.tar.bz2 | |
Work on docs
Diffstat (limited to 'docs/api-guide')
| -rw-r--r-- | docs/api-guide/requests.md | 9 | ||||
| -rw-r--r-- | docs/api-guide/responses.md | 34 |
2 files changed, 27 insertions, 16 deletions
diff --git a/docs/api-guide/requests.md b/docs/api-guide/requests.md index a371143a..91563e3b 100644 --- a/docs/api-guide/requests.md +++ b/docs/api-guide/requests.md @@ -111,6 +111,15 @@ If you do need to access the raw content directly, you should use the `.stream` For more information see the [browser enhancements documentation]. +--- + +# Standard HttpRequest attributes + +As REST framework's `Request` extends Django's `HttpRequest`, all the other standard attributes and methods are also available. For example the `request.META` dictionary is available as normal. + +Note that due to implementation reasons the `Request` class does not inherit from `HttpRequest` class, but instead extends the class using composition. + + [cite]: https://groups.google.com/d/topic/django-developers/dxI4qVzrBY4/discussion [parsers documentation]: parsers.md [authentication documentation]: authentication.md diff --git a/docs/api-guide/responses.md b/docs/api-guide/responses.md index b0de6824..395decda 100644 --- a/docs/api-guide/responses.md +++ b/docs/api-guide/responses.md @@ -16,7 +16,7 @@ Unless you want to heavily customize REST framework for some reason, you should --- -# Methods +# Creating responses ## Response() @@ -35,21 +35,6 @@ Arguments: * `template_name`: A template name to use if `HTMLRenderer` is selected. * `headers`: A dictionary of HTTP headers to use in the response. -## .render() - -**Signature:** `.render()` - -This methd is called to render the serialized data of the response into the final response content. When `.render()` is called, the response content will be set to the result of calling the `.render(data, accepted_media_type)` method on the accepted renderer instance. - -You won't typically need to call `.render()` yourself, as it's handled by Django's standard response cycle. - -## Standard response methods - -The `Response` class extends `SimpleTemplateResponse`, and all the usual methods are also available on the response. For example you can set headers on the response in the standard way: - - response = Response() - response['Cache-Control'] = 'no-cache' - --- # Attributes @@ -88,5 +73,22 @@ A dictionary of additional context information that will be passed to the render Set automatically by the `APIView` or `@api_view` immediately before the response is returned from the view. +--- + +# Standard HttpResponse attributes + +The `Response` class extends `SimpleTemplateResponse`, and all the usual attributes and methods are also available on the response. For example you can set headers on the response in the standard way: + + response = Response() + response['Cache-Control'] = 'no-cache' + +## .render() + +**Signature:** `.render()` + +As with any other `TemplateResponse`, this methd is called to render the serialized data of the response into the final response content. When `.render()` is called, the response content will be set to the result of calling the `.render(data, accepted_media_type, renderer_context)` method on the `accepted_renderer` instance. + +You won't typically need to call `.render()` yourself, as it's handled by Django's standard response cycle. + [cite]: https://docs.djangoproject.com/en/dev/ref/template-response/ [statuscodes]: status-codes.md |
