Allow durationfield to be represented as ISO-8601 #8527
Replies: 3 comments 1 reply
-
Could you start by giving an example of what format you'd want to see? date/times and durations are different types of things, and it's not clear to me that ISO-8601 is relevant here. |
Beta Was this translation helpful? Give feedback.
-
@tomchristie I am referencing to the ISO-8601 which is also supported by
As of now the django-rest-framework/rest_framework/fields.py Lines 1404 to 1405 in 2506d0b Allowing to use ISO representation for duration (via |
Beta Was this translation helpful? Give feedback.
-
@tomchristie I have opened a PR #8532 (in draft) with the updated doc. I have tried to keep it aligned with date-time fields, I'm waiting for your opinion. |
Beta Was this translation helpful? Give feedback.
-
As of now for date and time field there is a config to specify the output format which allows to use the ISO-8601 format (which is also supported by django in its parsers).
Whereas
DurationField
are always formatted using django base methodduration_string
. There is no way to configure a whole project to useduration_iso_string
instead to have durations always formatted as ISO-8601.Is it true that you can override the
DurationField
to use that format, but when you have a dependency which uses this kind of field this option would lead to overwrite that code, bringing maintenance problems.It would be cool if there could be a settings option to switch between base and ISO representation of durations.
Beta Was this translation helpful? Give feedback.
All reactions