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/responses.md | |
| parent | b3477b3b6c1431a03089d68828c13568d02dc990 (diff) | |
| download | django-rest-framework-7a89d7a770d310f8b72178c561fcd04e6c15e5c4.tar.bz2 | |
Work on docs
Diffstat (limited to 'docs/api-guide/responses.md')
| -rw-r--r-- | docs/api-guide/responses.md | 34 | 
1 files changed, 18 insertions, 16 deletions
| 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 | 
