mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 11:33:59 +03:00
Work on docs
This commit is contained in:
parent
b3477b3b6c
commit
7a89d7a770
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
# The Browsable API
|
||||
|
||||
> It is a profoundly erroneous truism... that we should cultivate the habit of thinking of what we are doing. The precise opposite is the case. Civilization advances by extending the number of important operations which we can perform without thinking about them.
|
||||
>
|
||||
> — [Alfred North Whitehead][cite], An Introduction to Mathematics (1911)
|
||||
|
||||
|
||||
API may stand for Application *Programming* Interface, but humans have to be able to read the APIs, too; someone has to do the programming. Django REST Framework supports generating human-friendly HTML output for each resource when the `HTML` format is requested. These pages allow for easy browsing of resources, as well as forms for submitting data to the resources using `POST`, `PUT`, and `DELETE`.
|
||||
|
||||
## URLs
|
||||
|
@ -85,7 +90,7 @@ The context that's available to the template:
|
|||
|
||||
For more advanced customization, such as not having a Bootstrap basis or tighter integration with the rest of your site, you can simply choose not to have `api.html` extend `base.html`. Then the page content and capabilities are entirely up to you.
|
||||
|
||||
|
||||
[cite]: http://en.wikiquote.org/wiki/Alfred_North_Whitehead
|
||||
[drfreverse]: ../api-guide/reverse.md
|
||||
[ffjsonview]: https://addons.mozilla.org/en-US/firefox/addon/jsonview/
|
||||
[chromejsonview]: https://chrome.google.com/webstore/detail/chklaanhfefbnpoihckbnefhakgolnmc
|
||||
|
|
Loading…
Reference in New Issue
Block a user