aboutsummaryrefslogtreecommitdiffstats
path: root/api-guide
diff options
context:
space:
mode:
Diffstat (limited to 'api-guide')
-rw-r--r--api-guide/authentication.html2
-rw-r--r--api-guide/fields.html3
-rw-r--r--api-guide/filtering.html6
-rw-r--r--api-guide/generic-views.html4
-rw-r--r--api-guide/pagination.html3
-rw-r--r--api-guide/permissions.html2
-rw-r--r--api-guide/renderers.html13
-rw-r--r--api-guide/serializers.html9
-rw-r--r--api-guide/viewsets.html2
9 files changed, 30 insertions, 14 deletions
diff --git a/api-guide/authentication.html b/api-guide/authentication.html
index f8e75399..89091469 100644
--- a/api-guide/authentication.html
+++ b/api-guide/authentication.html
@@ -287,7 +287,7 @@ WSGIPassAuthorization On
<p><strong>Note:</strong> If you use <code>BasicAuthentication</code> in production you must ensure that your API is only available over <code>https</code>. You should also ensure that your API clients will always re-request the username and password at login, and will never store those details to persistent storage.</p>
<h2 id="tokenauthentication">TokenAuthentication</h2>
<p>This authentication scheme uses a simple token-based HTTP Authentication scheme. Token authentication is appropriate for client-server setups, such as native desktop and mobile clients.</p>
-<p>To use the <code>TokenAuthentication</code> scheme, include <code>rest_framework.authtoken</code> in your <code>INSTALLED_APPS</code> setting:</p>
+<p>To use the <code>TokenAuthentication</code> scheme you'll need to <a href="#setting-the-authentication-scheme">configure the authentication classes</a> to include <code>TokenAuthentication</code>, and additionally include <code>rest_framework.authtoken</code> in your <code>INSTALLED_APPS</code> setting:</p>
<pre class="prettyprint lang-py"><code>INSTALLED_APPS = (
...
'rest_framework.authtoken'
diff --git a/api-guide/fields.html b/api-guide/fields.html
index 458f879d..49e356e7 100644
--- a/api-guide/fields.html
+++ b/api-guide/fields.html
@@ -324,7 +324,8 @@ or <code>django.db.models.fields.TextField</code>.</p>
<p>Corresponds to <code>django.db.models.fields.SlugField</code>.</p>
<p><strong>Signature:</strong> <code>SlugField(max_length=50, min_length=None)</code></p>
<h2 id="choicefield">ChoiceField</h2>
-<p>A field that can accept a value out of a limited set of choices.</p>
+<p>A field that can accept a value out of a limited set of choices. Optionally takes a <code>blank_display_value</code> parameter that customizes the display value of an empty choice.</p>
+<p><strong>Signature:</strong> <code>ChoiceField(choices=(), blank_display_value=None)</code></p>
<h2 id="emailfield">EmailField</h2>
<p>A text representation, validates the text to be a valid e-mail address.</p>
<p>Corresponds to <code>django.db.models.fields.EmailField</code></p>
diff --git a/api-guide/filtering.html b/api-guide/filtering.html
index 76b1375f..76b18e00 100644
--- a/api-guide/filtering.html
+++ b/api-guide/filtering.html
@@ -214,7 +214,7 @@
from myapp.serializers import PurchaseSerializer
from rest_framework import generics
-class PurchaseList(generics.ListAPIView)
+class PurchaseList(generics.ListAPIView):
serializer_class = PurchaseSerializer
def get_queryset(self):
@@ -231,7 +231,7 @@ class PurchaseList(generics.ListAPIView)
<pre class="prettyprint lang-py"><code>url('^purchases/(?P&lt;username&gt;.+)/$', PurchaseList.as_view()),
</code></pre>
<p>You could then write a view that returned a purchase queryset filtered by the username portion of the URL:</p>
-<pre class="prettyprint lang-py"><code>class PurchaseList(generics.ListAPIView)
+<pre class="prettyprint lang-py"><code>class PurchaseList(generics.ListAPIView):
serializer_class = PurchaseSerializer
def get_queryset(self):
@@ -245,7 +245,7 @@ class PurchaseList(generics.ListAPIView)
<h2 id="filtering-against-query-parameters">Filtering against query parameters</h2>
<p>A final example of filtering the initial queryset would be to determine the initial queryset based on query parameters in the url.</p>
<p>We can override <code>.get_queryset()</code> to deal with URLs such as <code>http://example.com/api/purchases?username=denvercoder9</code>, and filter the queryset only if the <code>username</code> parameter is included in the URL:</p>
-<pre class="prettyprint lang-py"><code>class PurchaseList(generics.ListAPIView)
+<pre class="prettyprint lang-py"><code>class PurchaseList(generics.ListAPIView):
serializer_class = PurchaseSerializer
def get_queryset(self):
diff --git a/api-guide/generic-views.html b/api-guide/generic-views.html
index 0e349ca3..03a70c6c 100644
--- a/api-guide/generic-views.html
+++ b/api-guide/generic-views.html
@@ -261,7 +261,7 @@ class UserList(generics.ListCreateAPIView):
</ul>
<p><strong>Shortcuts</strong>:</p>
<ul>
-<li><code>model</code> - This shortcut may be used instead of setting either (or both) of the <code>queryset</code>/<code>serializer_class</code> attributes, although using the explicit style is generally preferred. If used instead of <code>serializer_class</code>, then then <code>DEFAULT_MODEL_SERIALIZER_CLASS</code> setting will determine the base serializer class. Note that <code>model</code> is only ever used for generating a default queryset or serializer class - the <code>queryset</code> and <code>serializer_class</code> attributes are always preferred if provided.</li>
+<li><code>model</code> - This shortcut may be used instead of setting either (or both) of the <code>queryset</code>/<code>serializer_class</code> attributes, although using the explicit style is generally preferred. If used instead of <code>serializer_class</code>, then <code>DEFAULT_MODEL_SERIALIZER_CLASS</code> setting will determine the base serializer class. Note that <code>model</code> is only ever used for generating a default queryset or serializer class - the <code>queryset</code> and <code>serializer_class</code> attributes are always preferred if provided.</li>
</ul>
<p><strong>Pagination</strong>:</p>
<p>The following attributes are used to control pagination when used with list views.</p>
@@ -350,7 +350,7 @@ class UserList(generics.ListCreateAPIView):
<p>You won't typically need to override the following methods, although you might need to call into them if you're writing custom views using <code>GenericAPIView</code>.</p>
<ul>
<li><code>get_serializer_context(self)</code> - Returns a dictionary containing any extra context that should be supplied to the serializer. Defaults to including <code>'request'</code>, <code>'view'</code> and <code>'format'</code> keys.</li>
-<li><code>get_serializer(self, instance=None, data=None, files=None, many=False, partial=False)</code> - Returns a serializer instance.</li>
+<li><code>get_serializer(self, instance=None, data=None, files=None, many=False, partial=False, allow_add_remove=False)</code> - Returns a serializer instance.</li>
<li><code>get_pagination_serializer(self, page)</code> - Returns a serializer instance to use with paginated data.</li>
<li><code>paginate_queryset(self, queryset)</code> - Paginate a queryset if required, either returning a page object, or <code>None</code> if pagination is not configured for this view.</li>
<li><code>filter_queryset(self, queryset)</code> - Given a queryset, filter it with whichever filter backends are in use, returning a new queryset.</li>
diff --git a/api-guide/pagination.html b/api-guide/pagination.html
index d8c67612..c83a78ee 100644
--- a/api-guide/pagination.html
+++ b/api-guide/pagination.html
@@ -277,7 +277,8 @@ def user_list(request):
paginate_by_param = 'page_size'
max_paginate_by = 100
</code></pre>
-<p>Note that using a <code>paginate_by</code> value of <code>None</code> will turn off pagination for the view.</p>
+<p>Note that using a <code>paginate_by</code> value of <code>None</code> will turn off pagination for the view.
+Note if you use the <code>PAGINATE_BY_PARAM</code> settings, you also have to set the <code>paginate_by_param</code> attribute in your view to <code>None</code> in order to turn off pagination for those requests that contain the <code>paginate_by_param</code> parameter.</p>
<p>For more complex requirements such as serialization that differs depending on the requested media type you can override the <code>.get_paginate_by()</code> and <code>.get_pagination_serializer_class()</code> methods.</p>
<hr />
<h1 id="custom-pagination-serializers">Custom pagination serializers</h1>
diff --git a/api-guide/permissions.html b/api-guide/permissions.html
index a42b9e3c..5422ae35 100644
--- a/api-guide/permissions.html
+++ b/api-guide/permissions.html
@@ -239,7 +239,7 @@ or if you override the <code>get_object</code> method on a generic view, then yo
<p>You can also set the authentication policy on a per-view, or per-viewset basis,
using the <code>APIView</code> class based views.</p>
<pre class="prettyprint lang-py"><code>from rest_framework.permissions import IsAuthenticated
-from rest_framework.responses import Response
+from rest_framework.response import Response
from rest_framework.views import APIView
class ExampleView(APIView):
diff --git a/api-guide/renderers.html b/api-guide/renderers.html
index 80dd5fe6..75b8aee5 100644
--- a/api-guide/renderers.html
+++ b/api-guide/renderers.html
@@ -177,6 +177,7 @@
<li><a href="#unicodejsonrenderer">UnicodeJSONRenderer</a></li>
<li><a href="#jsonprenderer">JSONPRenderer</a></li>
<li><a href="#yamlrenderer">YAMLRenderer</a></li>
+<li><a href="#unicodeyamlrenderer">UnicodeYAMLRenderer</a></li>
<li><a href="#xmlrenderer">XMLRenderer</a></li>
<li><a href="#templatehtmlrenderer">TemplateHTMLRenderer</a></li>
<li><a href="#statichtmlrenderer">StaticHTMLRenderer</a></li>
@@ -303,6 +304,18 @@ def user_count_view(request, format=None):
<h2 id="yamlrenderer">YAMLRenderer</h2>
<p>Renders the request data into <code>YAML</code>. </p>
<p>Requires the <code>pyyaml</code> package to be installed.</p>
+<p>Note that non-ascii characters will be rendered using <code>\uXXXX</code> character escape. For example:</p>
+<pre class="prettyprint lang-py"><code>unicode black star: "\u2605"
+</code></pre>
+<p><strong>.media_type</strong>: <code>application/yaml</code></p>
+<p><strong>.format</strong>: <code>'.yaml'</code></p>
+<p><strong>.charset</strong>: <code>utf-8</code></p>
+<h2 id="unicodeyamlrenderer">UnicodeYAMLRenderer</h2>
+<p>Renders the request data into <code>YAML</code>. </p>
+<p>Requires the <code>pyyaml</code> package to be installed.</p>
+<p>Note that non-ascii characters will not be character escaped. For example:</p>
+<pre class="prettyprint lang-py"><code>unicode black star: ★
+</code></pre>
<p><strong>.media_type</strong>: <code>application/yaml</code></p>
<p><strong>.format</strong>: <code>'.yaml'</code></p>
<p><strong>.charset</strong>: <code>utf-8</code></p>
diff --git a/api-guide/serializers.html b/api-guide/serializers.html
index 2536b149..ae5b2c36 100644
--- a/api-guide/serializers.html
+++ b/api-guide/serializers.html
@@ -186,6 +186,7 @@
<li><a href="#relational-fields">Relational fields</a></li>
<li class="main"><a href="#hyperlinkedmodelserializer">HyperlinkedModelSerializer</a></li>
<li><a href="#how-hyperlinked-views-are-determined">How hyperlinked views are determined</a></li>
+<li><a href="#overriding-the-url-field-behavior">Overriding the URL field behavior</a></li>
<li class="main"><a href="#advanced-serializer-usage">Advanced serializer usage</a></li>
<li><a href="#dynamically-modifying-fields">Dynamically modifying fields</a></li>
<li><a href="#customising-the-default-fields">Customising the default fields</a></li>
@@ -260,8 +261,8 @@ json
<h3 id="customizing-field-representation">Customizing field representation</h3>
<p>Sometimes when serializing objects, you may not want to represent everything exactly the way it is in your model.</p>
<p>If you need to customize the serialized value of a particular field, you can do this by creating a <code>transform_&lt;fieldname&gt;</code> method. For example if you needed to render some markdown from a text field:</p>
-<pre class="prettyprint lang-py"><code>description = serializers.TextField()
-description_html = serializers.TextField(source='description', read_only=True)
+<pre class="prettyprint lang-py"><code>description = serializers.CharField()
+description_html = serializers.CharField(source='description', read_only=True)
def transform_description_html(self, obj, value):
from django.contrib.markup.templatetags.markup import markdown
@@ -565,7 +566,7 @@ The <code>ModelSerializer</code> class lets you automatically create a Serialize
model = Account
fields = ('url', 'account_name', 'users', 'created')
</code></pre>
-<h2 id="overiding-the-url-field-behavior">Overiding the URL field behavior</h2>
+<h2 id="overriding-the-url-field-behavior">Overriding the URL field behavior</h2>
<p>The name of the URL field defaults to 'url'. You can override this globally, by using the <code>URL_FIELD_NAME</code> setting.</p>
<p>You can also override this on a per-serializer basis by using the <code>url_field_name</code> option on the serializer, like so:</p>
<pre class="prettyprint lang-py"><code>class AccountSerializer(serializers.HyperlinkedModelSerializer):
@@ -575,7 +576,7 @@ The <code>ModelSerializer</code> class lets you automatically create a Serialize
url_field_name = 'account_url'
</code></pre>
<p><strong>Note</strong>: The generic view implementations normally generate a <code>Location</code> header in response to successful <code>POST</code> requests. Serializers using <code>url_field_name</code> option will not have this header automatically included by the view. If you need to do so you will ned to also override the view's <code>get_success_headers()</code> method.</p>
-<p>You can also overide the URL field's view name and lookup field without overriding the field explicitly, by using the <code>view_name</code> and <code>lookup_field</code> options, like so:</p>
+<p>You can also override the URL field's view name and lookup field without overriding the field explicitly, by using the <code>view_name</code> and <code>lookup_field</code> options, like so:</p>
<pre class="prettyprint lang-py"><code>class AccountSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Account
diff --git a/api-guide/viewsets.html b/api-guide/viewsets.html
index f1d16ba6..73536a1d 100644
--- a/api-guide/viewsets.html
+++ b/api-guide/viewsets.html
@@ -311,7 +311,7 @@ class UserViewSet(viewsets.ModelViewSet):
def set_password(self, request, pk=None):
...
</code></pre>
-<p>The <code>@action</code> decorator will route <code>POST</code> requests by default, but may also accept other HTTP methods, by using the <code>method</code> argument. For example:</p>
+<p>The <code>@action</code> decorator will route <code>POST</code> requests by default, but may also accept other HTTP methods, by using the <code>methods</code> argument. For example:</p>
<pre class="prettyprint lang-py"><code> @action(methods=['POST', 'DELETE'])
def unset_password(self, request, pk=None):
...