From 106c8db6f5cacf1e37978d5cf13c9fde3ca29ce9 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 12 Jun 2014 12:22:09 +0100 Subject: Latest docs build --- api-guide/authentication.html | 2 +- api-guide/fields.html | 3 ++- api-guide/filtering.html | 6 +++--- api-guide/generic-views.html | 4 ++-- api-guide/pagination.html | 3 ++- api-guide/permissions.html | 2 +- api-guide/renderers.html | 13 +++++++++++++ api-guide/serializers.html | 9 +++++---- api-guide/viewsets.html | 2 +- 9 files changed, 30 insertions(+), 14 deletions(-) (limited to 'api-guide') 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
Note: If you use BasicAuthentication in production you must ensure that your API is only available over https. 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.
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.
-To use the TokenAuthentication scheme, include rest_framework.authtoken in your INSTALLED_APPS setting:
To use the TokenAuthentication scheme you'll need to configure the authentication classes to include TokenAuthentication, and additionally include rest_framework.authtoken in your INSTALLED_APPS setting:
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 django.db.models.fields.TextField.
Corresponds to django.db.models.fields.SlugField.
Signature: SlugField(max_length=50, min_length=None)
ChoiceField
-A field that can accept a value out of a limited set of choices.
+A field that can accept a value out of a limited set of choices. Optionally takes a blank_display_value parameter that customizes the display value of an empty choice.
+Signature: ChoiceField(choices=(), blank_display_value=None)
EmailField
A text representation, validates the text to be a valid e-mail address.
Corresponds to django.db.models.fields.EmailField
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)
url('^purchases/(?P<username>.+)/$', PurchaseList.as_view()),
You could then write a view that returned a purchase queryset filtered by the username portion of the URL:
-class PurchaseList(generics.ListAPIView)
+class PurchaseList(generics.ListAPIView):
serializer_class = PurchaseSerializer
def get_queryset(self):
@@ -245,7 +245,7 @@ class PurchaseList(generics.ListAPIView)
Filtering against query parameters
A final example of filtering the initial queryset would be to determine the initial queryset based on query parameters in the url.
We can override .get_queryset() to deal with URLs such as http://example.com/api/purchases?username=denvercoder9, and filter the queryset only if the username parameter is included in the URL:
-class PurchaseList(generics.ListAPIView)
+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):
Shortcuts:
-model - This shortcut may be used instead of setting either (or both) of the queryset/serializer_class attributes, although using the explicit style is generally preferred. If used instead of serializer_class, then then DEFAULT_MODEL_SERIALIZER_CLASS setting will determine the base serializer class. Note that model is only ever used for generating a default queryset or serializer class - the queryset and serializer_class attributes are always preferred if provided.
+model - This shortcut may be used instead of setting either (or both) of the queryset/serializer_class attributes, although using the explicit style is generally preferred. If used instead of serializer_class, then DEFAULT_MODEL_SERIALIZER_CLASS setting will determine the base serializer class. Note that model is only ever used for generating a default queryset or serializer class - the queryset and serializer_class attributes are always preferred if provided.
Pagination:
The following attributes are used to control pagination when used with list views.
@@ -350,7 +350,7 @@ class UserList(generics.ListCreateAPIView):
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 GenericAPIView.
get_serializer_context(self) - Returns a dictionary containing any extra context that should be supplied to the serializer. Defaults to including 'request', 'view' and 'format' keys.
-get_serializer(self, instance=None, data=None, files=None, many=False, partial=False) - Returns a serializer instance.
+get_serializer(self, instance=None, data=None, files=None, many=False, partial=False, allow_add_remove=False) - Returns a serializer instance.
get_pagination_serializer(self, page) - Returns a serializer instance to use with paginated data.
paginate_queryset(self, queryset) - Paginate a queryset if required, either returning a page object, or None if pagination is not configured for this view.
filter_queryset(self, queryset) - Given a queryset, filter it with whichever filter backends are in use, returning a new queryset.
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
-Note that using a paginate_by value of None will turn off pagination for the view.
+Note that using a paginate_by value of None will turn off pagination for the view.
+Note if you use the PAGINATE_BY_PARAM settings, you also have to set the paginate_by_param attribute in your view to None in order to turn off pagination for those requests that contain the paginate_by_param parameter.
For more complex requirements such as serialization that differs depending on the requested media type you can override the .get_paginate_by() and .get_pagination_serializer_class() methods.
Custom pagination serializers
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 get_object method on a generic view, then yo
You can also set the authentication policy on a per-view, or per-viewset basis,
using the APIView class based views.
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 @@
UnicodeJSONRenderer
JSONPRenderer
YAMLRenderer
+UnicodeYAMLRenderer
XMLRenderer
TemplateHTMLRenderer
StaticHTMLRenderer
@@ -303,6 +304,18 @@ def user_count_view(request, format=None):
YAMLRenderer
Renders the request data into YAML.
Requires the pyyaml package to be installed.
+Note that non-ascii characters will be rendered using \uXXXX character escape. For example:
+unicode black star: "\u2605"
+
+.media_type: application/yaml
+.format: '.yaml'
+.charset: utf-8
+UnicodeYAMLRenderer
+Renders the request data into YAML.
+Requires the pyyaml package to be installed.
+Note that non-ascii characters will not be character escaped. For example:
+unicode black star: ★
+
.media_type: application/yaml
.format: '.yaml'
.charset: utf-8
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 @@
Relational fields
HyperlinkedModelSerializer
How hyperlinked views are determined
+Overriding the URL field behavior
Advanced serializer usage
Dynamically modifying fields
Customising the default fields
@@ -260,8 +261,8 @@ json
Customizing field representation
Sometimes when serializing objects, you may not want to represent everything exactly the way it is in your model.
If you need to customize the serialized value of a particular field, you can do this by creating a transform_<fieldname> method. For example if you needed to render some markdown from a text field:
-description = serializers.TextField()
-description_html = serializers.TextField(source='description', read_only=True)
+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 ModelSerializer class lets you automatically create a Serialize
model = Account
fields = ('url', 'account_name', 'users', 'created')
-Overiding the URL field behavior
+Overriding the URL field behavior
The name of the URL field defaults to 'url'. You can override this globally, by using the URL_FIELD_NAME setting.
You can also override this on a per-serializer basis by using the url_field_name option on the serializer, like so:
class AccountSerializer(serializers.HyperlinkedModelSerializer):
@@ -575,7 +576,7 @@ The ModelSerializer class lets you automatically create a Serialize
url_field_name = 'account_url'
Note: The generic view implementations normally generate a Location header in response to successful POST requests. Serializers using url_field_name 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 get_success_headers() method.
-You can also overide the URL field's view name and lookup field without overriding the field explicitly, by using the view_name and lookup_field options, like so:
+You can also override the URL field's view name and lookup field without overriding the field explicitly, by using the view_name and lookup_field options, like so:
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):
...
-The @action decorator will route POST requests by default, but may also accept other HTTP methods, by using the method argument. For example:
+The @action decorator will route POST requests by default, but may also accept other HTTP methods, by using the methods argument. For example:
@action(methods=['POST', 'DELETE'])
def unset_password(self, request, pk=None):
...
--
cgit v1.2.3