8000 Updating docs · martync/django-rest-framework@4f7b028 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f7b028

Browse files
committed
Updating docs
1 parent c20ebe9 commit 4f7b028

File tree

2 files changed

+47
-34
lines changed

2 files changed

+47
-34
lines changed

docs/api-guide/fields.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -181,26 +181,10 @@ Corresponds to `django.forms.fields.RegexField`
181181

182182
**Signature:** `RegexField(regex, max_length=None, min_length=None)`
183183

184-
## DateField
185-
186-
A date representation.
187-
188-
Optionally takes `format` as parameter to replace the matching pattern.
189-
190-
Corresponds to `django.db.models.fields.DateField`
191-
192-
**Signature:** `DateField(input_formats=None, output_format=False)`
193-
194-
- `input_formats` designates which input formats are supported. This will override the `DATE_INPUT_FORMATS`
195-
196-
- `output_format` designates which output format will be used. This will override the `DATE_OUTPUT_FORMAT`
197-
198184
## DateTimeField
199185

200186
A date and time representation.
201187

202-
Optionally takes `format` as parameter to replace the matching pattern.
203-
204188
Corresponds to `django.db.models.fields.DateTimeField`
205189

206190
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
213197
class Meta:
214198
model = Comment
215199

216-
**Signature:** `DateTimeField(input_formats=None, output_format=False)`
200+
**Signature:** `DateTimeField(format=None, input_formats=None)`
201+
202+
* `format` - A string representing the output format. If not specified, the `DATETIME_FORMAT` setting will be used, which defaults to `'iso8601'`.
203+
* `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']`.
204+
205+
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'`)
206+
207+
## DateField
208+
209+
A date representation.
210+
211+
Corresponds to `django.db.models.fields.DateField`
212+
213+
**Signature:** `DateField(format=None, input_formats=None)`
217214

218-
- `input_formats` designates which input formats are supported. This will override the `DATETIME_INPUT_FORMATS`
215+
* `format` - A string representing the output format. If not specified, the `DATE_FORMAT` setting will be used, which defaults to `'iso8601'`.
216+
* `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']`.
219217

220-
- `output_format` designates which output format will be used. This will override the `DATETIME_OUTPUT_FORMAT`
218+
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'`)
221219

222220
## TimeField
223221

@@ -227,11 +225,12 @@ Optionally takes `format` as parameter to replace the matching pattern.
227225

228226
Corresponds to `django.db.models.fields.TimeField`
229227

230-
**Signature:** `TimeField(input_formats=None, output_format=False)`
228+
**Signature:** `TimeField(format=None, input_formats=None)`
231229

232-
- `input_formats` designates which input formats are supported. This will override the `TIME_INPUT_FORMATS`
230+
* `format` - A string representing the output format. If not specified, the `TIME_FORMAT` setting will be used, which defaults to `'iso8601'`.
231+
* `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']`.
233232

234-
- `output_format` designates which output format will be used. This will override the `TIME_OUTPUT_FORMAT`
233+
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'`)
235234

236235
## IntegerField
237236

@@ -276,3 +275,5 @@ Django's regular [FILE_UPLOAD_HANDLERS] are used for handling uploaded files.
276275

277276
[cite]: https://docs.djangoproject.com/en/dev/ref/forms/api/#django.forms.Form.cleaned_data
278277
[FILE_UPLOAD_HANDLERS]: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FILE_UPLOAD_HANDLERS
278+
[strftime]: http://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior
279+
[iso8601]: http://www.w3.org/TR/NOTE-datetime

docs/api-guide/settings.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,28 +174,40 @@ The name of a parameter in the URL conf that may be used to provide a format suf
174174

175175
Default: `'format'`
176176

177-
## DATE_INPUT_FORMATS
178-
179-
Default: `ISO8601`
177+
## DATETIME_FORMAT
180178

181-
## DATE_OUTPUT_FORMAT
179+
A format string that should be used by default for `DateTimeField` serializer fields.
182180

183-
Default: `ISO8601`
181+
Default: `'iso8601'`
184182

185183
## DATETIME_INPUT_FORMATS
186184

187-
Default: `ISO8601`
185+
A list of format strings that should be used by default for parsing inputs to `DateTimeField` serializer fields.
188186

189-
## DATETIME_OUTPUT_FORMAT
187+
Default: `['iso8601']`
190188

191-
Default: `ISO8601`
189+
## DATE_FORMAT
192190

193-
## TIME_INPUT_FORMATS
191+
A format string that should be used by default for `DateField` serializer fields.
192+
193+
Default: `'iso8601'`
194+
195+
## DATE_INPUT_FORMATS
194196

195-
Default: `ISO8601`
197+
A list of format strings that should be used by default for parsing inputs to `DateField` serializer fields.
198+
199+
Default: `['iso8601']`
200+
201+
## TIME_FORMAT
202+
203+
A format string that should be used by default for `TimeField` serializer fields.
204+
205+
Default: `'iso8601'`
206+
207+
## TIME_INPUT_FORMATS
196208

197-
## TIME_OUTPUT_FORMAT
209+
A list of format strings that should be used by default for parsing inputs to `TimeField` serializer fields.
198210

199-
Default: `ISO8601`
211+
Default: `['iso8601']`
200212

201213
[cite]: http://www.python.org/dev/peps/pep-0020/

0 commit comments

Comments
 (0)
0