Commit e628d9eb by Tom Christie

Update documentation

parent ccb2b8ff
File added
......@@ -65,7 +65,7 @@
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../metadata">
Next <i class="icon-arrow-right icon-white"></i>
</a>
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../pagination">
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../versioning">
<i class="icon-arrow-left icon-white"></i> Previous
</a>
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
......@@ -188,6 +188,10 @@
<a href="../pagination">Pagination</a>
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li class="active" >
<a href=".">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......@@ -394,10 +386,18 @@
</li>
<li>
<a href="#notfound">NotFound</a>
</li>
<li>
<a href="#methodnotallowed">MethodNotAllowed</a>
</li>
<li>
<a href="#notacceptable">NotAcceptable</a>
</li>
<li>
<a href="#unsupportedmediatype">UnsupportedMediaType</a>
</li>
......@@ -464,7 +464,7 @@ Content-Length: 94
</code></pre>
<h2 id="custom-exception-handling">Custom exception handling</h2>
<p>You can implement custom exception handling by creating a handler function that converts exceptions raised in your API views into response objects. This allows you to control the style of error responses used by your API.</p>
<p>The function must take a single argument, which is the exception to be handled, and should either return a <code>Response</code> object, or return <code>None</code> if the exception cannot be handled. If the handler returns <code>None</code> then the exception will be re-raised and Django will return a standard HTTP 500 'server error' response.</p>
<p>The function must take a pair of arguments, this first is the exception to be handled, and the second is a dictionary containing any extra context such as the view currently being handled. The exception handler function should either return a <code>Response</code> object, or return <code>None</code> if the exception cannot be handled. If the handler returns <code>None</code> then the exception will be re-raised and Django will return a standard HTTP 500 'server error' response.</p>
<p>For example, you might want to ensure that all error responses include the HTTP status code in the body of the response, like so:</p>
<pre><code>HTTP/1.1 405 Method Not Allowed
Content-Type: application/json
......@@ -475,10 +475,10 @@ Content-Length: 62
<p>In order to alter the style of the response, you could write the following custom exception handler:</p>
<pre><code>from rest_framework.views import exception_handler
def custom_exception_handler(exc):
def custom_exception_handler(exc, context):
# Call REST framework's default exception handler first,
# to get the standard error response.
response = exception_handler(exc)
response = exception_handler(exc, context)
# Now add the HTTP status code to the response.
if response is not None:
......@@ -486,6 +486,7 @@ def custom_exception_handler(exc):
return response
</code></pre>
<p>The context argument is not used by the default handler, but can be useful if the exception handler needs further information such as the view currently being handled, which can be accessed as <code>context['view']</code>.</p>
<p>The exception handler must also be configured in your settings, using the <code>EXCEPTION_HANDLER</code> setting key. For example:</p>
<pre><code>REST_FRAMEWORK = {
'EXCEPTION_HANDLER': 'my_project.my_app.utils.custom_exception_handler'
......@@ -526,10 +527,18 @@ class ServiceUnavailable(APIException):
<p><strong>Signature:</strong> <code>PermissionDenied(detail=None)</code></p>
<p>Raised when an authenticated request fails the permission checks.</p>
<p>By default this exception results in a response with the HTTP status code "403 Forbidden".</p>
<h2 id="notfound">NotFound</h2>
<p><strong>Signature:</strong> <code>NotFound(detail=None)</code></p>
<p>Raised when a resource does not exists at the given URL. This exception is equivalent to the standard <code>Http404</code> Django exception.</p>
<p>By default this exception results in a response with the HTTP status code "404 Not Found".</p>
<h2 id="methodnotallowed">MethodNotAllowed</h2>
<p><strong>Signature:</strong> <code>MethodNotAllowed(method, detail=None)</code></p>
<p>Raised when an incoming request occurs that does not map to a handler method on the view.</p>
<p>By default this exception results in a response with the HTTP status code "405 Method Not Allowed".</p>
<h2 id="notacceptable">NotAcceptable</h2>
<p><strong>Signature:</strong> <code>NotAcceptable(detail=None)</code></p>
<p>Raised when an incoming request occurs with an <code>Accept</code> header that cannot be satisfied by any of the available renderers.</p>
<p>By default this exception results in a response with the HTTP status code "406 Not Acceptable".</p>
<h2 id="unsupportedmediatype">UnsupportedMediaType</h2>
<p><strong>Signature:</strong> <code>UnsupportedMediaType(media_type, detail=None)</code></p>
<p>Raised if there are no parsers that can handle the content type of the request data when accessing <code>request.data</code>.</p>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......@@ -661,11 +653,12 @@ color_channel = serializers.ChoiceField(
<h2 id="charfield">CharField</h2>
<p>A text representation. Optionally validates the text to be shorter than <code>max_length</code> and longer than <code>min_length</code>.</p>
<p>Corresponds to <code>django.db.models.fields.CharField</code> or <code>django.db.models.fields.TextField</code>.</p>
<p><strong>Signature:</strong> <code>CharField(max_length=None, min_length=None, allow_blank=False)</code></p>
<p><strong>Signature:</strong> <code>CharField(max_length=None, min_length=None, allow_blank=False, trim_whitespace=True)</code></p>
<ul>
<li><code>max_length</code> - Validates that the input contains no more than this number of characters.</li>
<li><code>min_length</code> - Validates that the input contains no fewer than this number of characters.</li>
<li><code>allow_blank</code> - If set to <code>True</code> then the empty string should be considered a valid value. If set to <code>False</code> then the empty string is considered invalid and will raise a validation error. Defaults to <code>False</code>.</li>
<li><code>trim_whitespace</code> - If set to <code>True</code> then leading and trailing whitespace is trimmed. Defaults to <code>True</code>.</li>
</ul>
<p>The <code>allow_null</code> option is also available for string fields, although its usage is discouraged in favor of <code>allow_blank</code>. It is valid to set both <code>allow_blank=True</code> and <code>allow_null=True</code>, but doing so means that there will be two differing types of empty value permissible for string representations, which can lead to data inconsistencies and subtle application bugs.</p>
<h2 id="emailfield">EmailField</h2>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......@@ -568,11 +560,9 @@ class UserList(generics.ListCreateAPIView):
<p><strong>Pagination</strong>:</p>
<p>The following attributes are used to control pagination when used with list views.</p>
<ul>
<li><code>paginate_by</code> - The size of pages to use with paginated data. If set to <code>None</code> then pagination is turned off. If unset this uses the same value as the <code>PAGINATE_BY</code> setting, which defaults to <code>None</code>.</li>
<li><code>paginate_by_param</code> - The name of a query parameter, which can be used by the client to override the default page size to use for pagination. If unset this uses the same value as the <code>PAGINATE_BY_PARAM</code> setting, which defaults to <code>None</code>.</li>
<li><code>pagination_serializer_class</code> - The pagination serializer class to use when determining the style of paginated responses. Defaults to the same value as the <code>DEFAULT_PAGINATION_SERIALIZER_CLASS</code> setting.</li>
<li><code>page_kwarg</code> - The name of a URL kwarg or URL query parameter which can be used by the client to control which page is requested. Defaults to <code>'page'</code>.</li>
<li><code>pagination_class</code> - The pagination class that should be used when paginating list results. Defaults to the same value as the <code>DEFAULT_PAGINATION_CLASS</code> setting, which is <code>'rest_framework.pagination.PageNumberPagination'</code>.</li>
</ul>
<p>Note that usage of the <code>paginate_by</code>, <code>paginate_by_param</code> and <code>page_kwarg</code> attributes are now pending deprecation. The <code>pagination_serializer_class</code> attribute and <code>DEFAULT_PAGINATION_SERIALIZER_CLASS</code> setting have been removed completely. Pagination settings should instead be controlled by overriding a pagination class and setting any configuration attributes there. See the pagination documentation for more details.</p>
<p><strong>Filtering</strong>:</p>
<ul>
<li><code>filter_backends</code> - A list of filter backend classes that should be used for filtering the queryset. Defaults to the same value as the <code>DEFAULT_FILTER_BACKENDS</code> setting.</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......@@ -378,14 +370,6 @@
</li>
<li>
<a href="#yamlparser">YAMLParser</a>
</li>
<li>
<a href="#xmlparser">XMLParser</a>
</li>
<li>
<a href="#formparser">FormParser</a>
</li>
......@@ -430,6 +414,14 @@
<li>
<a href="#yaml">YAML</a>
</li>
<li>
<a href="#xml">XML</a>
</li>
<li>
<a href="#messagepack">MessagePack</a>
</li>
......@@ -472,34 +464,34 @@ sending more complex data than simple forms</p>
<p>As an example, if you are sending <code>json</code> encoded data using jQuery with the <a href="http://api.jquery.com/jQuery.ajax/">.ajax() method</a>, you should make sure to include the <code>contentType: 'application/json'</code> setting.</p>
<hr />
<h2 id="setting-the-parsers">Setting the parsers</h2>
<p>The default set of parsers may be set globally, using the <code>DEFAULT_PARSER_CLASSES</code> setting. For example, the following settings would allow requests with <code>YAML</code> content.</p>
<p>The default set of parsers may be set globally, using the <code>DEFAULT_PARSER_CLASSES</code> setting. For example, the following settings would allow only requests with <code>JSON</code> content, instead of the default of JSON or form data.</p>
<pre><code>REST_FRAMEWORK = {
'DEFAULT_PARSER_CLASSES': (
'rest_framework.parsers.YAMLParser',
'rest_framework.parsers.JSONParser',
)
}
</code></pre>
<p>You can also set the parsers used for an individual view, or viewset,
using the <code>APIView</code> class based views.</p>
<pre><code>from rest_framework.parsers import YAMLParser
<pre><code>from rest_framework.parsers import JSONParser
from rest_framework.response import Response
from rest_framework.views import APIView
class ExampleView(APIView):
"""
A view that can accept POST requests with YAML content.
A view that can accept POST requests with JSON content.
"""
parser_classes = (YAMLParser,)
parser_classes = (JSONParser,)
def post(self, request, format=None):
return Response({'received data': request.data})
</code></pre>
<p>Or, if you're using the <code>@api_view</code> decorator with function based views.</p>
<pre><code>@api_view(['POST'])
@parser_classes((YAMLParser,))
@parser_classes((JSONParser,))
def example_view(request, format=None):
"""
A view that can accept POST requests with YAML content.
A view that can accept POST requests with JSON content.
"""
return Response({'received data': request.data})
</code></pre>
......@@ -508,16 +500,6 @@ def example_view(request, format=None):
<h2 id="jsonparser">JSONParser</h2>
<p>Parses <code>JSON</code> request content.</p>
<p><strong>.media_type</strong>: <code>application/json</code></p>
<h2 id="yamlparser">YAMLParser</h2>
<p>Parses <code>YAML</code> request content.</p>
<p>Requires the <code>pyyaml</code> package to be installed.</p>
<p><strong>.media_type</strong>: <code>application/yaml</code></p>
<h2 id="xmlparser">XMLParser</h2>
<p>Parses REST framework's default style of <code>XML</code> request content.</p>
<p>Note that the <code>XML</code> markup language is typically used as the base language for more strictly defined domain-specific languages, such as <code>RSS</code>, <code>Atom</code>, and <code>XHTML</code>.</p>
<p>If you are considering using <code>XML</code> for your API, you may want to consider implementing a custom renderer and parser for your specific requirements, and using an existing domain-specific media-type, or creating your own custom XML-based media-type.</p>
<p>Requires the <code>defusedxml</code> package to be installed.</p>
<p><strong>.media_type</strong>: <code>application/xml</code></p>
<h2 id="formparser">FormParser</h2>
<p>Parses HTML form content. <code>request.data</code> will be populated with a <code>QueryDict</code> of data.</p>
<p>You will typically want to use both <code>FormParser</code> and <code>MultiPartParser</code> together in order to fully support HTML form data.</p>
......@@ -561,7 +543,7 @@ def example_view(request, format=None):
<p>Optional. If supplied, this argument will be a dictionary containing any additional context that may be required to parse the request content.</p>
<p>By default this will include the following keys: <code>view</code>, <code>request</code>, <code>args</code>, <code>kwargs</code>.</p>
<h2 id="example">Example</h2>
<p>The following is an example plaintext parser that will populate the <code>request.data</code> property with a string representing the body of the request. </p>
<p>The following is an example plaintext parser that will populate the <code>request.data</code> property with a string representing the body of the request.</p>
<pre><code>class PlainTextParser(BaseParser):
"""
Plain text parser.
......@@ -578,6 +560,38 @@ def parse(self, stream, media_type=None, parser_context=None):
<hr />
<h1 id="third-party-packages">Third party packages</h1>
<p>The following third party packages are also available.</p>
<h2 id="yaml">YAML</h2>
<p><a href="http://jpadilla.github.io/django-rest-framework-yaml/">REST framework YAML</a> provides <a href="http://www.yaml.org/">YAML</a> parsing and rendering support. It was previously included directly in the REST framework package, and is now instead supported as a third-party package.</p>
<h4 id="installation-configuration">Installation &amp; configuration</h4>
<p>Install using pip.</p>
<pre><code>$ pip install djangorestframework-yaml
</code></pre>
<p>Modify your REST framework settings.</p>
<pre><code>REST_FRAMEWORK = {
'DEFAULT_PARSER_CLASSES': (
'rest_framework_yaml.parsers.YAMLParser',
),
'DEFAULT_RENDERER_CLASSES': (
'rest_framework_yaml.renderers.YAMLRenderer',
),
}
</code></pre>
<h2 id="xml">XML</h2>
<p><a href="http://jpadilla.github.io/django-rest-framework-xml/">REST Framework XML</a> provides a simple informal XML format. It was previously included directly in the REST framework package, and is now instead supported as a third-party package.</p>
<h4 id="installation-configuration_1">Installation &amp; configuration</h4>
<p>Install using pip.</p>
<pre><code>$ pip install djangorestframework-xml
</code></pre>
<p>Modify your REST framework settings.</p>
<pre><code>REST_FRAMEWORK = {
'DEFAULT_PARSER_CLASSES': (
'rest_framework_xml.parsers.XMLParser',
),
'DEFAULT_RENDERER_CLASSES': (
'rest_framework_xml.renderers.XMLRenderer',
),
}
</code></pre>
<h2 id="messagepack">MessagePack</h2>
<p><a href="https://github.com/juanriaza/django-rest-framework-msgpack">MessagePack</a> is a fast, efficient binary serialization format. <a href="https://github.com/juanriaza">Juan Riaza</a> maintains the <a href="https://github.com/juanriaza/django-rest-framework-msgpack">djangorestframework-msgpack</a> package which provides MessagePack renderer and parser support for REST framework.</p>
<h2 id="camelcase-json">CamelCase JSON</h2>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......@@ -405,10 +397,6 @@
<a href="#djangoobjectpermissions">DjangoObjectPermissions</a>
</li>
<li>
<a href="#tokenhasreadwritescope">TokenHasReadWriteScope</a>
</li>
......@@ -575,16 +563,6 @@ def example_view(request, format=None):
<hr />
<p><strong>Note</strong>: If you need object level <code>view</code> permissions for <code>GET</code>, <code>HEAD</code> and <code>OPTIONS</code> requests, you'll want to consider also adding the <code>DjangoObjectPermissionsFilter</code> class to ensure that list endpoints only return results including objects for which the user has appropriate view permissions.</p>
<hr />
<h2 id="tokenhasreadwritescope">TokenHasReadWriteScope</h2>
<p>This permission class is intended for use with either of the <code>OAuthAuthentication</code> and <code>OAuth2Authentication</code> classes, and ties into the scoping that their backends provide.</p>
<p>Requests with a safe methods of <code>GET</code>, <code>OPTIONS</code> or <code>HEAD</code> will be allowed if the authenticated token has read permission.</p>
<p>Requests for <code>POST</code>, <code>PUT</code>, <code>PATCH</code> and <code>DELETE</code> will be allowed if the authenticated token has write permission.</p>
<p>This permission class relies on the implementations of the <a href="http://code.larlet.fr/django-oauth-plus">django-oauth-plus</a> and <a href="https://github.com/caffeinehit/django-oauth2-provider">django-oauth2-provider</a> libraries, which both provide limited support for controlling the scope of access tokens:</p>
<ul>
<li><code>django-oauth-plus</code>: Tokens are associated with a <code>Resource</code> class which has a <code>name</code>, <code>url</code> and <code>is_readonly</code> properties.</li>
<li><code>django-oauth2-provider</code>: Tokens are associated with a bitwise <code>scope</code> attribute, that defaults to providing bitwise values for <code>read</code> and/or <code>write</code>.</li>
</ul>
<p>If you require more advanced scoping for your API, such as restricting tokens to accessing a subset of functionality of your API then you will need to provide a custom permission class. See the source of the <code>django-oauth-plus</code> or <code>django-oauth2-provider</code> package for more details on scoping token access.</p>
<hr />
<h1 id="custom-permissions">Custom permissions</h1>
<p>To implement a custom permission, override <code>BasePermission</code> and implement either, or both, of the following methods:</p>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......@@ -492,7 +484,7 @@
<p><code>request.query_params</code> is a more correctly named synonym for <code>request.GET</code>.</p>
<p>For clarity inside your code, we recommend using <code>request.query_params</code> instead of the Django's standard <code>request.GET</code>. Doing so will help keep your codebase more correct and obvious - any HTTP method type may include query parameters, not just <code>GET</code> requests.</p>
<h2 id="data-and-files">.DATA and .FILES</h2>
<p>The old-style version 2.x <code>request.data</code> and <code>request.FILES</code> attributes are still available, but are now pending deprecation in favor of the unified <code>request.data</code> attribute.</p>
<p>The old-style version 2.x <code>request.DATA</code> and <code>request.FILES</code> attributes are still available, but are now pending deprecation in favor of the unified <code>request.data</code> attribute.</p>
<h2 id="query_params_1">.QUERY_PARAMS</h2>
<p>The old-style version 2.x <code>request.QUERY_PARAMS</code> attribute is still available, but is now pending deprecation in favor of the more pythonic <code>request.query_params</code>.</p>
<h2 id="parsers">.parsers</h2>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......@@ -378,6 +370,10 @@
</li>
<li>
<a href="#versioning-settings">Versioning settings</a>
</li>
<li>
<a href="#authentication-settings">Authentication settings</a>
</li>
......@@ -433,10 +429,10 @@
<p>For example your project's <code>settings.py</code> file might include something like this:</p>
<pre><code>REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.YAMLRenderer',
'rest_framework.renderers.JSONRenderer',
),
'DEFAULT_PARSER_CLASSES': (
'rest_framework.parsers.YAMLParser',
'rest_framework.parsers.JSONParser',
)
}
</code></pre>
......@@ -534,6 +530,17 @@ If set to <code>None</code> then generic filtering is disabled.</p>
<p>The name of a query parameter, which can be used to specify the ordering of results returned by <code>OrderingFilter</code>.</p>
<p>Default: <code>ordering</code></p>
<hr />
<h2 id="versioning-settings">Versioning settings</h2>
<h4 id="default_version">DEFAULT_VERSION</h4>
<p>The value that should be used for <code>request.version</code> when no versioning information is present.</p>
<p>Default: <code>None</code></p>
<h4 id="allowed_versions">ALLOWED_VERSIONS</h4>
<p>If set, this value will restrict the set of versions that may be returned by the versioning scheme, and will raise an error if the provided version if not in this set.</p>
<p>Default: <code>None</code></p>
<h4 id="version_parameter">VERSION_PARAMETER</h4>
<p>The string that should used for any versioning parameters, such as in the media type or URL query parameters.</p>
<p>Default: <code>'version'</code></p>
<hr />
<h2 id="authentication-settings">Authentication settings</h2>
<p><em>The following settings control the behavior of unauthenticated requests.</em></p>
<h4 id="unauthenticated_user">UNAUTHENTICATED_USER</h4>
......@@ -661,7 +668,7 @@ If set to <code>None</code> then generic filtering is disabled.</p>
<p>A string representing the function that should be used when returning a response for any given exception. If the function returns <code>None</code>, a 500 error will be raised.</p>
<p>This setting can be changed to support error responses other than the default <code>{"detail": "Failure..."}</code> responses. For example, you can use it to provide API responses like <code>{"errors": [{"message": "Failure...", "code": ""} ...]}</code>.</p>
<p>This should be a function with the following signature:</p>
<pre><code>exception_handler(exc)
<pre><code>exception_handler(exc, context)
</code></pre>
<ul>
<li><code>exc</code>: The exception.</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......@@ -469,7 +461,7 @@
<h1 id="apirequestfactory">APIRequestFactory</h1>
<p>Extends <a href="https://docs.djangoproject.com/en/dev/topics/testing/advanced/#django.test.client.RequestFactory">Django's existing <code>RequestFactory</code> class</a>.</p>
<h2 id="creating-test-requests">Creating test requests</h2>
<p>The <code>APIRequestFactory</code> class supports an almost identical API to Django's standard <code>RequestFactory</code> class. This means the that standard <code>.get()</code>, <code>.post()</code>, <code>.put()</code>, <code>.patch()</code>, <code>.delete()</code>, <code>.head()</code> and <code>.options()</code> methods are all available.</p>
<p>The <code>APIRequestFactory</code> class supports an almost identical API to Django's standard <code>RequestFactory</code> class. This means that the standard <code>.get()</code>, <code>.post()</code>, <code>.put()</code>, <code>.patch()</code>, <code>.delete()</code>, <code>.head()</code> and <code>.options()</code> methods are all available.</p>
<pre><code>from rest_framework.test import APIRequestFactory
# Using the standard RequestFactory API to create a form POST request
......@@ -506,7 +498,9 @@ request = factory.put('/notes/547/', content, content_type=content_type)
<h2 id="forcing-authentication">Forcing authentication</h2>
<p>When testing views directly using a request factory, it's often convenient to be able to directly authenticate the request, rather than having to construct the correct authentication credentials.</p>
<p>To forcibly authenticate a request, use the <code>force_authenticate()</code> method.</p>
<pre><code>factory = APIRequestFactory()
<pre><code>from rest_framework.tests import force_authenticate
factory = APIRequestFactory()
user = User.objects.get(username='olivia')
view = AccountDetail.as_view()
......@@ -538,9 +532,9 @@ response = view(request)
<p><strong>Note</strong>: It's worth noting that Django's standard <code>RequestFactory</code> doesn't need to include this option, because when using regular Django the CSRF validation takes place in middleware, which is not run when testing views directly. When using REST framework, CSRF validation takes place inside the view, so the request factory needs to disable view-level CSRF checks.</p>
<hr />
<h1 id="apiclient">APIClient</h1>
<p>Extends <a href="https://docs.djangoproject.com/en/dev/topics/testing/overview/#module-django.test.client">Django's existing <code>Client</code> class</a>.</p>
<p>Extends <a href="https://docs.djangoproject.com/en/dev/topics/testing/tools/#the-test-client">Django's existing <code>Client</code> class</a>.</p>
<h2 id="making-requests">Making requests</h2>
<p>The <code>APIClient</code> class supports the same request interface as <code>APIRequestFactory</code>. This means the that standard <code>.get()</code>, <code>.post()</code>, <code>.put()</code>, <code>.patch()</code>, <code>.delete()</code>, <code>.head()</code> and <code>.options()</code> methods are all available. For example:</p>
<p>The <code>APIClient</code> class supports the same request interface as Django's standard <code>Client</code> class. This means the that standard <code>.get()</code>, <code>.post()</code>, <code>.put()</code>, <code>.patch()</code>, <code>.delete()</code>, <code>.head()</code> and <code>.options()</code> methods are all available. For example:</p>
<pre><code>from rest_framework.test import APIClient
client = APIClient()
......@@ -646,13 +640,13 @@ self.assertEqual(response.content, '{"username": "lauren", "id": 4}')
</code></pre>
<h2 id="setting-the-available-formats">Setting the available formats</h2>
<p>If you need to test requests using something other than multipart or json requests, you can do so by setting the <code>TEST_REQUEST_RENDERER_CLASSES</code> setting.</p>
<p>For example, to add support for using <code>format='yaml'</code> in test requests, you might have something like this in your <code>settings.py</code> file.</p>
<p>For example, to add support for using <code>format='html'</code> in test requests, you might have something like this in your <code>settings.py</code> file.</p>
<pre><code>REST_FRAMEWORK = {
...
'TEST_REQUEST_RENDERER_CLASSES': (
'rest_framework.renderers.MultiPartRenderer',
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.YAMLRenderer'
'rest_framework.renderers.TemplateHTMLRenderer'
)
}
</code></pre>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../versioning">Versioning</a>
</li>
<li >
<a href="../content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......@@ -566,7 +558,7 @@ class UserViewSet(viewsets.ModelViewSet):
<p>The <code>ModelViewSet</code> class inherits from <code>GenericAPIView</code> and includes implementations for various actions, by mixing in the behavior of the various mixin classes.</p>
<p>The actions provided by the <code>ModelViewSet</code> class are <code>.list()</code>, <code>.retrieve()</code>, <code>.create()</code>, <code>.update()</code>, and <code>.destroy()</code>.</p>
<h4 id="example_1">Example</h4>
<p>Because <code>ModelViewSet</code> extends <code>GenericAPIView</code>, you'll normally need to provide at least the <code>queryset</code> and <code>serializer_class</code> attributes, or the <code>model</code> attribute shortcut. For example:</p>
<p>Because <code>ModelViewSet</code> extends <code>GenericAPIView</code>, you'll normally need to provide at least the <code>queryset</code> and <code>serializer_class</code> attributes. For example:</p>
<pre><code>class AccountViewSet(viewsets.ModelViewSet):
"""
A simple ViewSet for viewing and editing accounts.
......
......@@ -171,6 +171,25 @@ body{
background-attachment: fixed;
}
#main-content h1:first-of-type {
margin-top: 0
}
#main-content h1, #main-content h2 {
font-weight: 300;
margin-top: 20px
}
#main-content h3, #main-content h4, #main-content h5 {
font-weight: 500;
margin-top: 15px
}
#main-content img {
display: block;
margin: 40px auto;
}
/* custom navigation styles */
.navbar .navbar-inner{
......@@ -239,6 +258,10 @@ body a:hover{
}
}
h1 code, h2 code, h3 code, h4 code, h5 code {
color: #333;
}
/* sticky footer and footer */
html, body {
height: 100%;
......
File added
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="api-guide/versioning/">Versioning</a>
</li>
<li >
<a href="api-guide/content-negotiation/">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="topics/internationalization/">Internationalization</a>
</li>
<li >
<a href="topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="topics/rest-framework-2-announcement/">2.0 Announcement</a>
</li>
<li >
<a href="topics/2.2-announcement/">2.2 Announcement</a>
</li>
<li >
<a href="topics/2.3-announcement/">2.3 Announcement</a>
</li>
<li >
<a href="topics/2.4-announcement/">2.4 Announcement</a>
<a href="topics/3.0-announcement/">3.0 Announcement</a>
</li>
<li >
<a href="topics/3.0-announcement/">3.0 Announcement</a>
<a href="topics/3.1-announcement/">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="topics/release-notes/">Release Notes</a>
</li>
<li >
<a href="topics/credits/">Credits</a>
</li>
</ul>
</li>
......@@ -489,7 +481,7 @@
<p>Some reasons you might want to use REST framework:</p>
<ul>
<li>The <a href="http://restframework.herokuapp.com/">Web browsable API</a> is a huge usability win for your developers.</li>
<li><a href="api-guide/authentication/">Authentication policies</a> including <a href="./api-guide/authentication#oauthauthentication">OAuth1a</a> and <a href="./api-guide/authentication#oauth2authentication">OAuth2</a> out of the box.</li>
<li><a href="api-guide/authentication/">Authentication policies</a> including packages for <a href="./api-guide/authentication/#django-rest-framework-oauth">OAuth1a</a> and <a href="./api-guide/authentication/#django-oauth-toolkit">OAuth2</a>.</li>
<li><a href="api-guide/serializers/">Serialization</a> that supports both <a href="./api-guide/serializers#modelserializer">ORM</a> and <a href="./api-guide/serializers#serializers">non-ORM</a> data sources.</li>
<li>Customizable all the way down - just use <a href="./api-guide/views#function-based-views">regular function-based views</a> if you don't need the <a href="api-guide/generic-views/">more</a> <a href="api-guide/viewsets/">powerful</a> <a href="api-guide/routers/">features</a>.</li>
<li><a href="./.">Extensive documentation</a>, and <a href="https://groups.google.com/forum/?fromgroups#!forum/django-rest-framework">great community support</a>.</li>
......@@ -502,19 +494,14 @@
<p>REST framework requires the following:</p>
<ul>
<li>Python (2.6.5+, 2.7, 3.2, 3.3, 3.4)</li>
<li>Django (1.4.11+, 1.5.6+, 1.6.3+, 1.7)</li>
<li>Django (1.4.11+, 1.5.6+, 1.6.3+, 1.7, 1.8-beta)</li>
</ul>
<p>The following packages are optional:</p>
<ul>
<li><a href="http://pypi.python.org/pypi/Markdown/">Markdown</a> (2.1.0+) - Markdown support for the browsable API.</li>
<li><a href="http://pypi.python.org/pypi/PyYAML">PyYAML</a> (3.10+) - YAML content-type support.</li>
<li><a href="https://pypi.python.org/pypi/defusedxml">defusedxml</a> (0.3+) - XML content-type support.</li>
<li><a href="http://pypi.python.org/pypi/django-filter">django-filter</a> (0.9.2+) - Filtering support.</li>
<li><a href="https://bitbucket.org/david/django-oauth-plus/wiki/Home">django-oauth-plus</a> (2.0+) and <a href="https://github.com/simplegeo/python-oauth2">oauth2</a> (1.5.211+) - OAuth 1.0a support.</li>
<li><a href="https://github.com/caffeinehit/django-oauth2-provider">django-oauth2-provider</a> (0.2.3+) - OAuth 2.0 support.</li>
<li><a href="https://github.com/lukaszb/django-guardian">django-guardian</a> (1.1.1+) - Object level permissions support.</li>
</ul>
<p><strong>Note</strong>: The <code>oauth2</code> Python package is badly misnamed, and actually provides OAuth 1.0a support. Also note that packages required for both OAuth 1.0a, and OAuth 2.0 are not yet Python 3 compatible.</p>
<h2 id="installation">Installation</h2>
<p>Install using <code>pip</code>, including any optional packages you want...</p>
<pre><code>pip install djangorestframework
......@@ -612,6 +599,7 @@ urlpatterns = [
<li><a href="api-guide/throttling/">Throttling</a></li>
<li><a href="api-guide/filtering/">Filtering</a></li>
<li><a href="api-guide/pagination/">Pagination</a></li>
<li><a href="api-guide/versioning/">Versioning</a></li>
<li><a href="api-guide/content-negotiation/">Content negotiation</a></li>
<li><a href="api-guide/metadata/">Metadata</a></li>
<li><a href="api-guide/format-suffixes/">Format suffixes</a></li>
......@@ -632,14 +620,10 @@ urlpatterns = [
<li><a href="topics/third-party-resources/">Third Party Resources</a></li>
<li><a href="topics/contributing/">Contributing to REST framework</a></li>
<li><a href="topics/project-management/">Project management</a></li>
<li><a href="topics/rest-framework-2-announcement/">2.0 Announcement</a></li>
<li><a href="topics/2.2-announcement/">2.2 Announcement</a></li>
<li><a href="topics/2.3-announcement/">2.3 Announcement</a></li>
<li><a href="topics/2.4-announcement/">2.4 Announcement</a></li>
<li><a href="topics/3.0-announcement/">3.0 Announcement</a></li>
<li><a href="topics/3.1-announcement/">3.1 Announcement</a></li>
<li><a href="topics/kickstarter-announcement/">Kickstarter Announcement</a></li>
<li><a href="topics/release-notes/">Release Notes</a></li>
<li><a href="topics/credits/">Credits</a></li>
</ul>
<h2 id="development">Development</h2>
<p>See the <a href="topics/contributing/">Contribution guidelines</a> for information on how to clone
......
......@@ -62,10 +62,10 @@
<div class="navbar-inner">
<div class="container-fluid">
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../kickstarter-announcement">
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../3.1-announcement">
Next <i class="icon-arrow-right icon-white"></i>
</a>
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../2.4-announcement">
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../project-management">
<i class="icon-arrow-left icon-white"></i> Previous
</a>
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../../api-guide/versioning">Versioning</a>
</li>
<li >
<a href="../../api-guide/content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../internationalization">Internationalization</a>
</li>
<li >
<a href="../ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -259,36 +267,20 @@
<a href="../project-management">Project management</a>
</li>
<li >
<a href="../rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../2.4-announcement">2.4 Announcement</a>
</li>
<li class="active" >
<a href=".">3.0 Announcement</a>
</li>
<li >
<a href="../kickstarter-announcement">Kickstarter Announcement</a>
<a href="../3.1-announcement">3.1 Announcement</a>
</li>
<li >
<a href="../release-notes">Release Notes</a>
<a href="../kickstarter-announcement">Kickstarter Announcement</a>
</li>
<li >
<a href="../credits">Credits</a>
<a href="../release-notes">Release Notes</a>
</li>
</ul>
......
......@@ -65,7 +65,7 @@
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../browser-enhancements">
Next <i class="icon-arrow-right icon-white"></i>
</a>
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../documenting-your-api">
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../internationalization">
<i class="icon-arrow-left icon-white"></i> Previous
</a>
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../../api-guide/versioning">Versioning</a>
</li>
<li >
<a href="../../api-guide/content-negotiation">Content negotiation</a>
</li>
......@@ -231,6 +235,10 @@
<a href="../documenting-your-api">Documenting your API</a>
</li>
<li >
<a href="../internationalization">Internationalization</a>
</li>
<li class="active" >
<a href=".">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../2.4-announcement">2.4 Announcement</a>
<a href="../3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../3.0-announcement">3.0 Announcement</a>
<a href="../3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../release-notes">Release Notes</a>
</li>
<li >
<a href="../credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../../api-guide/versioning">Versioning</a>
</li>
<li >
<a href="../../api-guide/content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../internationalization">Internationalization</a>
</li>
<li >
<a href="../ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../2.4-announcement">2.4 Announcement</a>
<a href="../3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../3.0-announcement">3.0 Announcement</a>
<a href="../3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../release-notes">Release Notes</a>
</li>
<li >
<a href="../credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../../api-guide/versioning">Versioning</a>
</li>
<li >
<a href="../../api-guide/content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../internationalization">Internationalization</a>
</li>
<li >
<a href="../ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../2.4-announcement">2.4 Announcement</a>
<a href="../3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../3.0-announcement">3.0 Announcement</a>
<a href="../3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../release-notes">Release Notes</a>
</li>
<li >
<a href="../credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../../api-guide/versioning">Versioning</a>
</li>
<li >
<a href="../../api-guide/content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../internationalization">Internationalization</a>
</li>
<li >
<a href="../ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../2.4-announcement">2.4 Announcement</a>
<a href="../3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../3.0-announcement">3.0 Announcement</a>
<a href="../3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../release-notes">Release Notes</a>
</li>
<li >
<a href="../credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -62,7 +62,7 @@
<div class="navbar-inner">
<div class="container-fluid">
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../ajax-csrf-cors">
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../internationalization">
Next <i class="icon-arrow-right icon-white"></i>
</a>
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../../api-guide/settings">
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../../api-guide/versioning">Versioning</a>
</li>
<li >
<a href="../../api-guide/content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../internationalization">Internationalization</a>
</li>
<li >
<a href="../ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../2.4-announcement">2.4 Announcement</a>
<a href="../3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../3.0-announcement">3.0 Announcement</a>
<a href="../3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../release-notes">Release Notes</a>
</li>
<li >
<a href="../credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -65,7 +65,7 @@
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../release-notes">
Next <i class="icon-arrow-right icon-white"></i>
</a>
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../3.0-announcement">
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../3.1-announcement">
<i class="icon-arrow-left icon-white"></i> Previous
</a>
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../../api-guide/versioning">Versioning</a>
</li>
<li >
<a href="../../api-guide/content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../internationalization">Internationalization</a>
</li>
<li >
<a href="../ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../2.4-announcement">2.4 Announcement</a>
<a href="../3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../3.0-announcement">3.0 Announcement</a>
<a href="../3.1-announcement">3.1 Announcement</a>
</li>
<li class="active" >
......@@ -287,10 +283,6 @@
<a href="../release-notes">Release Notes</a>
</li>
<li >
<a href="../credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -62,7 +62,7 @@
<div class="navbar-inner">
<div class="container-fluid">
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../rest-framework-2-announcement">
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../3.0-announcement">
Next <i class="icon-arrow-right icon-white"></i>
</a>
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../contributing">
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../../api-guide/versioning">Versioning</a>
</li>
<li >
<a href="../../api-guide/content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../internationalization">Internationalization</a>
</li>
<li >
<a href="../ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../2.4-announcement">2.4 Announcement</a>
<a href="../3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../3.0-announcement">3.0 Announcement</a>
<a href="../3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../release-notes">Release Notes</a>
</li>
<li >
<a href="../credits">Credits</a>
</li>
</ul>
</li>
......@@ -366,6 +358,14 @@
</li>
<li>
<a href="#translations">Translations</a>
</li>
<li>
<a href="#project-requirements">Project requirements</a>
</li>
<li>
<a href="#project-ownership">Project ownership</a>
</li>
......@@ -438,10 +438,11 @@ To modify this process for future maintenance cycles make a pull request to the
<h4 id="responsibilities-of-team-members">Responsibilities of team members</h4>
<p>Team members have the following responsibilities.</p>
<ul>
<li>Add triage labels and milestones to tickets.</li>
<li>Close invalid or resolved tickets.</li>
<li>Add triage labels and milestones to tickets.</li>
<li>Merge finalized pull requests.</li>
<li>Build and deploy the documentation, using <code>mkdocs gh-deploy</code>.</li>
<li>Build and update the included translation packs.</li>
</ul>
<p>Further notes for maintainers:</p>
<ul>
......@@ -482,6 +483,48 @@ To modify this process for future releases make a pull request to the [project m
</code></pre>
<p>When pushing the release to PyPI ensure that your environment has been installed from our development <code>requirement.txt</code>, so that documentation and PyPI installs are consistently being built against a pinned set of packages.</p>
<hr />
<h2 id="translations">Translations</h2>
<p>The maintenance team are responsible for managing the translation packs include in REST framework. Translating the source strings into multiple languages is managed through the <a href="https://www.transifex.com/projects/p/django-rest-framework/">transifex service</a>.</p>
<h3 id="managing-transifex">Managing Transifex</h3>
<p>The <a href="https://pypi.python.org/pypi/transifex-client">official Transifex client</a> is used to upload and download translations to Transifex. The client is installed using pip:</p>
<pre><code>pip install transifex-client
</code></pre>
<p>To use it you'll need a login to Transifex which has a password, and you'll need to have administrative access to the Transifex project. You'll need to create a <code>~/.transifexrc</code> file which contains your credentials.</p>
<pre><code>[https://www.transifex.com]
username = ***
token = ***
password = ***
hostname = https://www.transifex.com
</code></pre>
<h3 id="upload-new-source-files">Upload new source files</h3>
<p>When any user visible strings are changed, they should be uploaded to Transifex so that the translators can start to translate them. To do this, just run:</p>
<pre><code># 1. Update the source django.po file, which is the US English version.
cd rest_framework
django-admin.py makemessages -l en_US
# 2. Push the source django.po file to Transifex.
cd ..
tx push -s
</code></pre>
<p>When pushing source files, Transifex will update the source strings of a resource to match those from the new source file.</p>
<p>Here's how differences between the old and new source files will be handled:</p>
<ul>
<li>New strings will be added.</li>
<li>Modified strings will be added as well.</li>
<li>Strings which do not exist in the new source file will be removed from the database, along with their translations. If that source strings gets re-added later then <a href="http://docs.transifex.com/guides/tm#let-tm-automatically-populate-translations">Transifex Translation Memory</a> will automatically include the translation string.</li>
</ul>
<h3 id="download-translations">Download translations</h3>
<p>When a translator has finished translating their work needs to be downloaded from Transifex into the REST framework repository. To do this, run:</p>
<pre><code># 3. Pull the translated django.po files from Transifex.
tx pull -a
cd rest_framework
# 4. Compile the binary .mo files for all supported languages.
django-admin.py compilemessages
</code></pre>
<hr />
<h2 id="project-requirements">Project requirements</h2>
<p>All our test requirements are pinned to exact versions, in order to ensure that our test runs are reproducible. We maintain the requirements in the <code>requirements</code> directory. The requirements files are referenced from the <code>tox.ini</code> configuration file, ensuring we have a single source of truth for package versions used in testing.</p>
<p>Package upgrades should generally be treated as isolated pull requests. You can check if there are any packages available at a newer version, by using the <code>pip list --outdated</code>.</p>
<hr />
<h2 id="project-ownership">Project ownership</h2>
<p>The PyPI package is owned by <code>@tomchristie</code>. As a backup <code>@j4mie</code> also has ownership of the package.</p>
<p>If <code>@tomchristie</code> ceases to participate in the project then <code>@j4mie</code> has responsibility for handing over ownership duties.</p>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../../api-guide/versioning">Versioning</a>
</li>
<li >
<a href="../../api-guide/content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../internationalization">Internationalization</a>
</li>
<li >
<a href="../ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../2.4-announcement">2.4 Announcement</a>
<a href="../3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../3.0-announcement">3.0 Announcement</a>
<a href="../3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../release-notes">Release Notes</a>
</li>
<li >
<a href="../credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../../api-guide/versioning">Versioning</a>
</li>
<li >
<a href="../../api-guide/content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../internationalization">Internationalization</a>
</li>
<li >
<a href="../ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../2.4-announcement">2.4 Announcement</a>
<a href="../3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../3.0-announcement">3.0 Announcement</a>
<a href="../3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../release-notes">Release Notes</a>
</li>
<li >
<a href="../credits">Credits</a>
</li>
</ul>
</li>
......@@ -512,6 +504,7 @@ You probably want to also tag the version now:
<li><a href="https://github.com/kumar303/hawkrest">hawkrest</a> - Provides Hawk HTTP Authorization.</li>
<li><a href="https://github.com/etoccalino/django-rest-framework-httpsignature">djangorestframework-httpsignature</a> - Provides an easy to use HTTP Signature Authentication mechanism.</li>
<li><a href="https://github.com/sunscrapers/djoser">djoser</a> - Provides a set of views to handle basic actions such as registration, login, logout, password reset and account activation.</li>
<li><a href="https://github.com/Tivix/django-rest-auth/">django-rest-auth</a> - Provides a set of REST API endpoints for registration, authentication (including social media authentication), password reset, retrieve and update user details, etc.</li>
</ul>
<h3 id="permissions">Permissions</h3>
<ul>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../../api-guide/versioning">Versioning</a>
</li>
<li >
<a href="../../api-guide/content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../../api-guide/versioning">Versioning</a>
</li>
<li >
<a href="../../api-guide/content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......@@ -479,7 +471,7 @@ def snippet_detail(request, pk):
return Response(status=status.HTTP_204_NO_CONTENT)
</code></pre>
<p>This should all feel very familiar - it is not a lot different from working with regular Django views.</p>
<p>Notice that we're no longer explicitly tying our requests or responses to a given content type. <code>request.data</code> can handle incoming <code>json</code> requests, but it can also handle <code>yaml</code> and other formats. Similarly we're returning response objects with data, but allowing REST framework to render the response into the correct content type for us.</p>
<p>Notice that we're no longer explicitly tying our requests or responses to a given content type. <code>request.data</code> can handle incoming <code>json</code> requests, but it can also handle other formats. Similarly we're returning response objects with data, but allowing REST framework to render the response into the correct content type for us.</p>
<h2 id="adding-optional-format-suffixes-to-our-urls">Adding optional format suffixes to our URLs</h2>
<p>To take advantage of the fact that our responses are no longer hardwired to a single content type let's add support for format suffixes to our API endpoints. Using format suffixes gives us URLs that explicitly refer to a given format, and means our API will be able to handle URLs such as <a href="http://example.com/api/items/4.json">http://example.com/api/items/4/.json</a>.</p>
<p>Start by adding a <code>format</code> keyword argument to both of the views, like so.</p>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../../api-guide/versioning">Versioning</a>
</li>
<li >
<a href="../../api-guide/content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../../api-guide/versioning">Versioning</a>
</li>
<li >
<a href="../../api-guide/content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../../api-guide/versioning">Versioning</a>
</li>
<li >
<a href="../../api-guide/content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......@@ -514,7 +506,7 @@ urlpatterns += [
<p>The list views for users and code snippets could end up returning quite a lot of instances, so really we'd like to make sure we paginate the results, and allow the API client to step through each of the individual pages.</p>
<p>We can change the default list style to use pagination, by modifying our <code>tutorial/settings.py</code> file slightly. Add the following setting:</p>
<pre><code>REST_FRAMEWORK = {
'PAGINATE_BY': 10
'PAGE_SIZE': 10
}
</code></pre>
<p>Note that settings in REST framework are all namespaced into a single dictionary setting, named 'REST_FRAMEWORK', which helps keep them well separated from your other project settings.</p>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../../api-guide/versioning">Versioning</a>
</li>
<li >
<a href="../../api-guide/content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......
......@@ -189,6 +189,10 @@
</li>
<li >
<a href="../../api-guide/versioning">Versioning</a>
</li>
<li >
<a href="../../api-guide/content-negotiation">Content negotiation</a>
</li>
......@@ -232,6 +236,10 @@
</li>
<li >
<a href="../../topics/internationalization">Internationalization</a>
</li>
<li >
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
</li>
......@@ -260,23 +268,11 @@
</li>
<li >
<a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>
</li>
<li >
<a href="../../topics/2.2-announcement">2.2 Announcement</a>
</li>
<li >
<a href="../../topics/2.3-announcement">2.3 Announcement</a>
</li>
<li >
<a href="../../topics/2.4-announcement">2.4 Announcement</a>
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
</li>
<li >
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
</li>
<li >
......@@ -287,10 +283,6 @@
<a href="../../topics/release-notes">Release Notes</a>
</li>
<li >
<a href="../../topics/credits">Credits</a>
</li>
</ul>
</li>
......@@ -496,7 +488,7 @@ urlpatterns = [
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAdminUser',),
'PAGINATE_BY': 10
'PAGE_SIZE': 10
}
</code></pre>
<p>Okay, we're done.</p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment