mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-07 13:54:47 +03:00
Change signature of DateTimeField
and add detail to format
- Signature is saying `format=None` while it is `format=empty`. This can lead to confusion, thinking the default behavior of the field is with `format=None`
This commit is contained in:
parent
f0f61aa077
commit
5d2e92fafe
|
@ -290,9 +290,9 @@ A date and time representation.
|
|||
|
||||
Corresponds to `django.db.models.fields.DateTimeField`.
|
||||
|
||||
**Signature:** `DateTimeField(format=None, input_formats=None)`
|
||||
**Signature:** `DateTimeField(format=empty, 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. The default value is [`empty`](https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/fields.py#L42), not `None`. You need to explicitly set `format=None` in order to get Python `datetime` object.
|
||||
* `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']`.
|
||||
|
||||
#### `DateTimeField` format strings.
|
||||
|
|
Loading…
Reference in New Issue
Block a user