You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*`format` - A string representing the output format. If not specified, this defaults to the same value as the `DURATION_FORMAT` settings key, which will be `'standard'` 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 `timedelta` objects should be returned by `to_representation`. In this case the date encoding will be determined by the renderer.
384
384
*`max_value` Validate that the duration provided is no greater than this value.
385
385
*`min_value` Validate that the duration provided is no less than this value.
386
386
387
+
#### `DurationField` format strings
388
+
Format strings may either be the special string `'iso-8601'`, which indicates that [ISO 8601][iso8601] style intervals should be used (eg `'P4DT1H15M20S'`), or the special string `'standard'`, which indicates that Django interval format `'[DD] [HH:[MM:]]ss[.uuuuuu]'` should be used (eg: `'4 1:15:20'`).
389
+
387
390
---
388
391
389
392
# Choice selection fields
@@ -552,7 +555,7 @@ For further examples on `HiddenField` see the [validators](validators.md) docume
552
555
553
556
---
554
557
555
-
**Note:**`HiddenField()` does not appear in `partial=True` serializer (when making `PATCH` request). This behavior might change in future, follow updates on [github discussion](https://github.com/encode/django-rest-framework/discussions/8259).
558
+
**Note:**`HiddenField()` does not appear in `partial=True` serializer (when making `PATCH` request). This behavior might change in future, follow updates on [github discussion](https://github.com/encode/django-rest-framework/discussions/8259).
Copy file name to clipboardExpand all lines: docs/api-guide/settings.md
+9
Original file line number
Diff line number
Diff line change
@@ -314,6 +314,15 @@ May be a list including the string `'iso-8601'` or Python [strftime format][strf
314
314
315
315
Default: `['iso-8601']`
316
316
317
+
318
+
#### DURATION_FORMAT
319
+
320
+
A format string that should be used by default for rendering the output of `DurationField` serializer fields. If `None`, then `DurationField` serializer fields will return Python `timedelta` objects, and the duration encoding will be determined by the renderer.
321
+
322
+
May be any of `None`, `'iso-8601'` or `'standard'` (the format accepted by `django.utils.dateparse.parse_duration`).
0 commit comments