From 3c7f07bc67e3ce0c6524808c2b27c312a47188da Mon Sep 17 00:00:00 2001
From: Tom Christie A date and time representation. Corresponds to Signature: Signature: A date representation. Corresponds to Signature: Signature: A time representation. Corresponds to Signature: Signature: Pagination is only performed automatically if you're using the generic views or viewsets. If you're using a regular Pagination can be turned off by setting the pagination class to The default pagination style may be set globally, using the The default pagination style may be set globally, using the Note that you need to set both the pagination class, and the page size that should be used. You can also set the pagination class on an individual view by using the If you want to modify particular aspects of the pagination style, you'll want to override one of the pagination classes, and set the attributes that you want to change. This pagination style mirrors the syntax used when looking up multiple database records. The client includes both a "limit" and an
+ This pagination style mirrors the syntax used when looking up multiple database records. The client includes both a "limit" and an
"offset" query parameter. The limit indicates the maximum number of items to return, and is equivalent to the Request: This is a great zero-configuration option for when you want to get up and
running really quickly. The only other available option to The other available options to May be used to pass the set of renderer classes that can be used to render schema output. May be used to pass the root URL for the schema. This can either be used to ensure that
+the schema URLs include a canonical hostname and schema, or to ensure that all the
+schema URLs include a path prefix. If you want more flexibility over the schema output then you'll need to consider
using May be used to pass the set of renderer classes that can be used to render the API root endpoint. The most common way to add a schema to your API is to use the DateTimeField
django.db.models.fields.DateTimeField
.DateTimeField(format=None, input_formats=None)
DateTimeField(format=api_settings.DATETIME_FORMAT, input_formats=None)
-
format
- A string representing the output format. If not specified, this defaults to the same value as the DATETIME_FORMAT
settings key, which will be 'iso-8601'
unless set. Setting to a format string indicates that to_representation
return values should be coerced to string output. Format strings are described below. Setting this value to None
indicates that Python datetime
objects should be returned by to_representation
. In this case the datetime encoding will be determined by the renderer.format
- A string representing the output format. If not specified, this defaults to the same value as the DATETIME_FORMAT
settings key, which will be 'iso-8601'
unless set. Setting to a format string indicates that to_representation
return values should be coerced to string output. Format strings are described below. Setting this value to None
indicates that Python datetime
objects should be returned by to_representation
. In this case the datetime encoding will be determined by the renderer.input_formats
- A list of strings representing the input formats which may be used to parse the date. If not specified, the DATETIME_INPUT_FORMATS
setting will be used, which defaults to ['iso-8601']
.
@@ -797,7 +797,7 @@ color_channel = serializers.ChoiceField(
DateTimeField
format strings.DateField
django.db.models.fields.DateField
DateField(format=None, input_formats=None)
DateField(format=api_settings.DATE_FORMAT, input_formats=None)
format
- A string representing the output format. If not specified, this defaults to the same value as the DATE_FORMAT
settings key, which will be 'iso-8601'
unless set. Setting to a format string indicates that to_representation
return values should be coerced to string output. Format strings are described below. Setting this value to None
indicates that Python date
objects should be returned by to_representation
. In this case the date encoding will be determined by the renderer.input_formats
- A list of strings representing the input formats which may be used to parse the date. If not specified, the DATE_INPUT_FORMATS
setting will be used, which defaults to ['iso-8601']
.TimeField
django.db.models.fields.TimeField
TimeField(format=None, input_formats=None)
TimeField(format=api_settings.TIME_FORMAT, input_formats=None)
format
- A string representing the output format. If not specified, this defaults to the same value as the TIME_FORMAT
settings key, which will be 'iso-8601'
unless set. Setting to a format string indicates that to_representation
return values should be coerced to string output. Format strings are described below. Setting this value to None
indicates that Python time
objects should be returned by to_representation
. In this case the time encoding will be determined by the renderer.input_formats
- A list of strings representing the input formats which may be used to parse the date. If not specified, the TIME_INPUT_FORMATS
setting will be used, which defaults to ['iso-8601']
.APIView
, you'll need to call into the pagination API yourself to ensure you return a paginated response. See the source code for the mixins.ListModelMixin
and generics.GenericAPIView
classes for an example.None
.Setting the pagination style
-DEFAULT_PAGINATION_CLASS
settings key. For example, to use the built-in limit/offset pagination, you would do:DEFAULT_PAGINATION_CLASS
and PAGE_SIZE
setting keys. For example, to use the built-in limit/offset pagination, you would do something like this:
+REST_FRAMEWORK = {
- 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination'
+ 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
+ 'PAGE_SIZE': 100
}
pagination_class
attribute. Typically you'll want to use the same pagination style throughout your API, although you might want to vary individual aspects of the pagination, such as default or maximum page size, on a per-view basis.Modifying the pagination style
LimitOffsetPagination
-page_size
in other styles. The offset indicates the starting position of the query in relation to the complete set of unpaginated items.GET https://api.example.org/accounts/?limit=100&offset=400
diff --git a/api-guide/schemas/index.html b/api-guide/schemas/index.html
index 05eefaa36..3b8885cb7 100644
--- a/api-guide/schemas/index.html
+++ b/api-guide/schemas/index.html
@@ -550,9 +550,9 @@ Content-Type: application/vnd.coreapi+json
DefaultRouter
is schema_renderers
, which
-may be used to pass the set of renderer classes that can be used to render
-schema output.DefaultRouter
are:schema_renderers
+
+from rest_framework.renderers import CoreJSONRenderer
from my_custom_package import APIBlueprintRenderer
@@ -560,8 +560,19 @@ router = DefaultRouter(schema_title='Server Monitoring API', schema_renderers=[
CoreJSONRenderer, APIBlueprintRenderer
])
schema_url
+router = DefaultRouter(
+ schema_title='Server Monitoring API',
+ schema_url='https://www.example.org/api/'
+)
+
SchemaGenerator
instead.root_renderers
+Using SchemaGenerator
SchemaGenerator
class to auto-generate the Document
instance, and to return that from a view.
Arguments:
title
- The name of the API. requiredurl
- The root URL of the API schema. This option is not required unless the schema is included under path prefix.patterns
- A list of URLs to inspect when generating the schema. Defaults to the project's URL conf.urlconf
- A URL conf module name to use when generating the schema. Defaults to settings.ROOT_URLCONF
.This class of status code indicates that further action needs to be taken by the user agent in order to fulfill the request.
@@ -483,6 +484,9 @@ HTTP_414_REQUEST_URI_TOO_LONG HTTP_415_UNSUPPORTED_MEDIA_TYPE HTTP_416_REQUESTED_RANGE_NOT_SATISFIABLE HTTP_417_EXPECTATION_FAILED +HTTP_422_UNPROCESSABLE_ENTITY +HTTP_423_LOCKED +HTTP_424_FAILED_DEPENDENCY HTTP_428_PRECONDITION_REQUIRED HTTP_429_TOO_MANY_REQUESTS HTTP_431_REQUEST_HEADER_FIELDS_TOO_LARGE @@ -496,6 +500,7 @@ HTTP_502_BAD_GATEWAY HTTP_503_SERVICE_UNAVAILABLE HTTP_504_GATEWAY_TIMEOUT HTTP_505_HTTP_VERSION_NOT_SUPPORTED +HTTP_507_INSUFFICIENT_STORAGE HTTP_511_NETWORK_AUTHENTICATION_REQUIRED### 3.4.1
+Date: 28th July 2016
+root_renderers
argument to DefaultRouter
. (#4323, #4268)url
and schema_url
arguments. (#4321, #4308, #4305)pagination_class = None
. (#4314, #4289)get_serializer_class
. (#4265, #4285)Accept
and Content-Type
headers. (#4287, #4313, #4281)Date: 14th July 2016