mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-14 05:36:50 +03:00
Doc style tweaks
This commit is contained in:
parent
9d8bce8f5b
commit
84958d131a
|
@ -56,7 +56,7 @@ The `Response` class extends `SimpleTemplateResponse`, and all the usual methods
|
||||||
|
|
||||||
## .data
|
## .data
|
||||||
|
|
||||||
The unrendered content of a `Request` object can be accessed using the `.data` attribute.
|
The unrendered content of a `Request` object.
|
||||||
|
|
||||||
## .status_code
|
## .status_code
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ The numeric status code of the HTTP response.
|
||||||
|
|
||||||
## .content
|
## .content
|
||||||
|
|
||||||
The rendered content of the response. `.render()` must have been called before `.content` can be accessed.
|
The rendered content of the response. The `.render()` method must have been called before `.content` can be accessed.
|
||||||
|
|
||||||
## .template_name
|
## .template_name
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ The following methods are called before dispatching to the handler method.
|
||||||
The following methods are called directly by the view's `.dispatch()` method.
|
The following methods are called directly by the view's `.dispatch()` method.
|
||||||
These perform any actions that need to occur before or after calling the handler methods such as `.get()`, `.post()`, `put()` and `.delete()`.
|
These perform any actions that need to occur before or after calling the handler methods such as `.get()`, `.post()`, `put()` and `.delete()`.
|
||||||
|
|
||||||
### .initial(self, request, *args, **kwargs)
|
### .initial(self, request, \*args, **kwargs)
|
||||||
|
|
||||||
Performs any actions that need to occur before the handler method gets called.
|
Performs any actions that need to occur before the handler method gets called.
|
||||||
This method is used to enforce permissions and throttling, and perform content negotiation.
|
This method is used to enforce permissions and throttling, and perform content negotiation.
|
||||||
|
@ -98,13 +98,13 @@ The default implementation handles any subclass of `rest_framework.exceptions.AP
|
||||||
|
|
||||||
If you need to customize the error responses your API returns you should subclass this method.
|
If you need to customize the error responses your API returns you should subclass this method.
|
||||||
|
|
||||||
### .initialize_request(self, request, *args, **kwargs)
|
### .initialize_request(self, request, \*args, **kwargs)
|
||||||
|
|
||||||
Ensures that the request object that is passed to the handler method is an instance of `Request`, rather than the usual Django `HttpRequest`.
|
Ensures that the request object that is passed to the handler method is an instance of `Request`, rather than the usual Django `HttpRequest`.
|
||||||
|
|
||||||
You won't typically need to override this method.
|
You won't typically need to override this method.
|
||||||
|
|
||||||
### .finalize_response(self, request, response, *args, **kwargs)
|
### .finalize_response(self, request, response, \*args, **kwargs)
|
||||||
|
|
||||||
Ensures that any `Response` object returned from the handler method will be rendered into the correct content type, as determined by the content negotation.
|
Ensures that any `Response` object returned from the handler method will be rendered into the correct content type, as determined by the content negotation.
|
||||||
|
|
||||||
|
|
24
docs/static/css/default.css
vendored
24
docs/static/css/default.css
vendored
|
@ -61,6 +61,30 @@ a.github:hover {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Footer */
|
||||||
|
/*
|
||||||
|
.footer p {
|
||||||
|
text-align: center;
|
||||||
|
color: gray;
|
||||||
|
border-top: 1px solid #DDD;
|
||||||
|
padding-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer a {
|
||||||
|
color: gray;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer a:hover {
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* */
|
||||||
|
body hr {
|
||||||
|
border-top: 1px dotted #A30000
|
||||||
|
}
|
||||||
|
|
||||||
/* Force TOC text to not overrun */
|
/* Force TOC text to not overrun */
|
||||||
#table-of-contents {
|
#table-of-contents {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
|
@ -89,6 +89,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="wrap">
|
||||||
|
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
|
|
||||||
|
@ -104,9 +106,19 @@
|
||||||
{{ content }}
|
{{ content }}
|
||||||
</div><!--/span-->
|
</div><!--/span-->
|
||||||
</div><!--/row-->
|
</div><!--/row-->
|
||||||
|
|
||||||
</div><!--/.fluid-container-->
|
</div><!--/.fluid-container-->
|
||||||
|
|
||||||
|
<div id="push"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<div class="row footer">
|
||||||
|
<div class="span12">
|
||||||
|
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
-->
|
||||||
|
|
||||||
<!-- Le javascript
|
<!-- Le javascript
|
||||||
================================================== -->
|
================================================== -->
|
||||||
<!-- Placed at the end of the document so the pages load faster -->
|
<!-- Placed at the end of the document so the pages load faster -->
|
||||||
|
|
|
@ -25,6 +25,7 @@ Now that we're inside a virtualenv environment, we can install our package requi
|
||||||
Okay, we're ready to get coding.
|
Okay, we're ready to get coding.
|
||||||
To get started, let's create a new project to work with.
|
To get started, let's create a new project to work with.
|
||||||
|
|
||||||
|
cd ~
|
||||||
django-admin.py startproject tutorial
|
django-admin.py startproject tutorial
|
||||||
cd tutorial
|
cd tutorial
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ Don't forget to sync the database for the first time.
|
||||||
|
|
||||||
## Creating a Serializer class
|
## Creating a Serializer class
|
||||||
|
|
||||||
We're going to create a simple Web API that we can use to edit these comment objects with. The first thing we need is a way of serializing and deserializing the objects into representations such as `json`. We do this by declaring serializers that work very similarly to Django's forms. Create a file in the project named `serializers.py` and add the following.
|
We're going to create a simple Web API that we can use to edit these comment objects with. The first thing we need is a way of serializing and deserializing the objects into representations such as `json`. We do this by declaring serializers that work very similarly to Django's forms. Create a file in the `blog` directory named `serializers.py` and add the following.
|
||||||
|
|
||||||
from blog import models
|
from blog import models
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
Loading…
Reference in New Issue
Block a user