mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-03-03 19:00:17 +03:00
Updating docs
This commit is contained in:
parent
c20ebe95f6
commit
4f7b028a0a
|
@ -181,26 +181,10 @@ Corresponds to `django.forms.fields.RegexField`
|
||||||
|
|
||||||
**Signature:** `RegexField(regex, max_length=None, min_length=None)`
|
**Signature:** `RegexField(regex, max_length=None, min_length=None)`
|
||||||
|
|
||||||
## DateField
|
|
||||||
|
|
||||||
A date representation.
|
|
||||||
|
|
||||||
Optionally takes `format` as parameter to replace the matching pattern.
|
|
||||||
|
|
||||||
Corresponds to `django.db.models.fields.DateField`
|
|
||||||
|
|
||||||
**Signature:** `DateField(input_formats=None, output_format=False)`
|
|
||||||
|
|
||||||
- `input_formats` designates which input formats are supported. This will override the `DATE_INPUT_FORMATS`
|
|
||||||
|
|
||||||
- `output_format` designates which output format will be used. This will override the `DATE_OUTPUT_FORMAT`
|
|
||||||
|
|
||||||
## DateTimeField
|
## DateTimeField
|
||||||
|
|
||||||
A date and time representation.
|
A date and time representation.
|
||||||
|
|
||||||
Optionally takes `format` as parameter to replace the matching pattern.
|
|
||||||
|
|
||||||
Corresponds to `django.db.models.fields.DateTimeField`
|
Corresponds to `django.db.models.fields.DateTimeField`
|
||||||
|
|
||||||
When using `ModelSerializer` or `HyperlinkedModelSerializer`, note that any model fields with `auto_now=True` or `auto_now_add=True` will use serializer fields that are `read_only=True` by default.
|
When using `ModelSerializer` or `HyperlinkedModelSerializer`, note that any model fields with `auto_now=True` or `auto_now_add=True` will use serializer fields that are `read_only=True` by default.
|
||||||
|
@ -213,11 +197,25 @@ If you want to override this behavior, you'll need to declare the `DateTimeField
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Comment
|
model = Comment
|
||||||
|
|
||||||
**Signature:** `DateTimeField(input_formats=None, output_format=False)`
|
**Signature:** `DateTimeField(format=None, input_formats=None)`
|
||||||
|
|
||||||
- `input_formats` designates which input formats are supported. This will override the `DATETIME_INPUT_FORMATS`
|
* `format` - A string representing the output format. If not specified, the `DATETIME_FORMAT` setting will be used, which defaults to `'iso8601'`.
|
||||||
|
* `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 `['iso8601']`.
|
||||||
|
|
||||||
- `output_format` designates which output format will be used. This will override the `DATETIME_OUTPUT_FORMAT`
|
DateTime format strings may either be [python strftime formats][strftime] which explicitly specifiy the format, or the special string `'is8601'`, which indicates that [ISO 8601][iso8601] style datetimes should be used. (eg `'2013-01-29T12:34:56.000000'`)
|
||||||
|
|
||||||
|
## DateField
|
||||||
|
|
||||||
|
A date representation.
|
||||||
|
|
||||||
|
Corresponds to `django.db.models.fields.DateField`
|
||||||
|
|
||||||
|
**Signature:** `DateField(format=None, input_formats=None)`
|
||||||
|
|
||||||
|
* `format` - A string representing the output format. If not specified, the `DATE_FORMAT` setting will be used, which defaults to `'iso8601'`.
|
||||||
|
* `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 `['iso8601']`.
|
||||||
|
|
||||||
|
Date format strings may either be [python strftime formats][strftime] which explicitly specifiy the format, or the special string `'is8601'`, which indicates that [ISO 8601][iso8601] style dates should be used. (eg `'2013-01-29'`)
|
||||||
|
|
||||||
## TimeField
|
## TimeField
|
||||||
|
|
||||||
|
@ -227,11 +225,12 @@ Optionally takes `format` as parameter to replace the matching pattern.
|
||||||
|
|
||||||
Corresponds to `django.db.models.fields.TimeField`
|
Corresponds to `django.db.models.fields.TimeField`
|
||||||
|
|
||||||
**Signature:** `TimeField(input_formats=None, output_format=False)`
|
**Signature:** `TimeField(format=None, input_formats=None)`
|
||||||
|
|
||||||
- `input_formats` designates which input formats are supported. This will override the `TIME_INPUT_FORMATS`
|
* `format` - A string representing the output format. If not specified, the `TIME_FORMAT` setting will be used, which defaults to `'iso8601'`.
|
||||||
|
* `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 `['iso8601']`.
|
||||||
|
|
||||||
- `output_format` designates which output format will be used. This will override the `TIME_OUTPUT_FORMAT`
|
Time format strings may either be [python strftime formats][strftime] which explicitly specifiy the format, or the special string `'is8601'`, which indicates that [ISO 8601][iso8601] style times should be used. (eg `'12:34:56.000000'`)
|
||||||
|
|
||||||
## IntegerField
|
## IntegerField
|
||||||
|
|
||||||
|
@ -276,3 +275,5 @@ Django's regular [FILE_UPLOAD_HANDLERS] are used for handling uploaded files.
|
||||||
|
|
||||||
[cite]: https://docs.djangoproject.com/en/dev/ref/forms/api/#django.forms.Form.cleaned_data
|
[cite]: https://docs.djangoproject.com/en/dev/ref/forms/api/#django.forms.Form.cleaned_data
|
||||||
[FILE_UPLOAD_HANDLERS]: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FILE_UPLOAD_HANDLERS
|
[FILE_UPLOAD_HANDLERS]: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FILE_UPLOAD_HANDLERS
|
||||||
|
[strftime]: http://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior
|
||||||
|
[iso8601]: http://www.w3.org/TR/NOTE-datetime
|
||||||
|
|
|
@ -174,28 +174,40 @@ The name of a parameter in the URL conf that may be used to provide a format suf
|
||||||
|
|
||||||
Default: `'format'`
|
Default: `'format'`
|
||||||
|
|
||||||
## DATE_INPUT_FORMATS
|
## DATETIME_FORMAT
|
||||||
|
|
||||||
Default: `ISO8601`
|
A format string that should be used by default for `DateTimeField` serializer fields.
|
||||||
|
|
||||||
## DATE_OUTPUT_FORMAT
|
Default: `'iso8601'`
|
||||||
|
|
||||||
Default: `ISO8601`
|
|
||||||
|
|
||||||
## DATETIME_INPUT_FORMATS
|
## DATETIME_INPUT_FORMATS
|
||||||
|
|
||||||
Default: `ISO8601`
|
A list of format strings that should be used by default for parsing inputs to `DateTimeField` serializer fields.
|
||||||
|
|
||||||
## DATETIME_OUTPUT_FORMAT
|
Default: `['iso8601']`
|
||||||
|
|
||||||
Default: `ISO8601`
|
## DATE_FORMAT
|
||||||
|
|
||||||
|
A format string that should be used by default for `DateField` serializer fields.
|
||||||
|
|
||||||
|
Default: `'iso8601'`
|
||||||
|
|
||||||
|
## DATE_INPUT_FORMATS
|
||||||
|
|
||||||
|
A list of format strings that should be used by default for parsing inputs to `DateField` serializer fields.
|
||||||
|
|
||||||
|
Default: `['iso8601']`
|
||||||
|
|
||||||
|
## TIME_FORMAT
|
||||||
|
|
||||||
|
A format string that should be used by default for `TimeField` serializer fields.
|
||||||
|
|
||||||
|
Default: `'iso8601'`
|
||||||
|
|
||||||
## TIME_INPUT_FORMATS
|
## TIME_INPUT_FORMATS
|
||||||
|
|
||||||
Default: `ISO8601`
|
A list of format strings that should be used by default for parsing inputs to `TimeField` serializer fields.
|
||||||
|
|
||||||
## TIME_OUTPUT_FORMAT
|
Default: `['iso8601']`
|
||||||
|
|
||||||
Default: `ISO8601`
|
|
||||||
|
|
||||||
[cite]: http://www.python.org/dev/peps/pep-0020/
|
[cite]: http://www.python.org/dev/peps/pep-0020/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user