From 9476365e6b0342a9468051a71ee8b26c4561beb4 Mon Sep 17 00:00:00 2001
From: Tom Christie Each field in a Form class is responsible not only for validating data, but also for "cleaning" it — normalizing it to a consistent format. Each field in a Form class is responsible not only for validating data, but also for "cleaning" it — normalizing it to a consistent format. Serializer fields handle converting between primitive values and internal datatypes. They also deal with validating input values, as well as retrieving and setting the values from their parent objects. Defaults to If set, this gives the default value that will be used for the field if no input value is supplied. If not set the default behavior is to not populate the attribute at all. If set, this gives the default value that will be used for the field if no input value is supplied. If not set the default behavior is to not populate the attribute at all. May be set to a function or other callable, in which case the value will be evaluated each time it is used. A list of Django validators that should be used to validate deserialized values. In the case of JSON this means the default datetime representation uses the ECMA 262 date time string specification. This is a subset of ISO 8601 which uses millisecond precision, and includes the 'Z' suffix for the UTC timezone, for example: Signature: DateTime format strings may either be Python strftime formats which explicitly specify the format, or the special string The drf-compound-fields package provides "compound" serializer fields, such as lists of simple values, which can be described by other fields rather than serializers with the For example: By default, the search parameter is named For more details, see the Django documentation. The The For example, to order users by username: The client may also specify reverse orderings by prefixing the field name with '-', like so:Serializer fields
-
True
.
-default
validators
@@ -346,7 +348,7 @@ or {
'url': 'http://example.com/api/accounts/3/',
'owner': 'http://example.com/api/users/12/',
- 'name': 'FooCorp business account',
+ 'name': 'FooCorp business account',
'expired': True
}
django.db.models.fields.TextField
.
2013-01-29T12:34:56.123Z
.DateTimeField(format=None, input_formats=None)
-
format
- A string representing the output format. If not specified, this defaults to None
, which indicates that Python datetime
objects should be returned by to_native
. 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 None
, which indicates that Python datetime
objects should be returned by to_native
. 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']
.'iso-8601'
, which indicates that ISO 8601 style datetimes should be used. (eg '2013-01-29T12:34:56.000000Z'
)Third party packages
+DRF Compound Fields
+many=True
option. Also provided are fields for typed dictionaries and values that can be either a specific type or a list of items of that type.
+search_fields = ('=username', '=email')
'search
', but this may be overridden with the SEARCH_PARAM
setting.
OrderingFilter
-OrderingFilter
class supports simple query parameter controlled ordering of results. To specify the result order, set a query parameter named 'ordering'
to the required field name. For example:OrderingFilter
class supports simple query parameter controlled ordering of results. By default, the query parameter is named 'ordering'
, but this may by overridden with the ORDERING_PARAM
setting.http://example.com/api/users?ordering=username
None
then generic filtering is disabled.
GET http://example.com/api/accounts?page_size=999
Default: None
The name of a query paramater, which can be used to specify the search term used by SearchFilter
.
Default: search
The name of a query paramater, which can be used to specify the ordering of results returned by OrderingFilter
.
Default: ordering
The following settings control the behavior of unauthenticated requests.