-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Two slightly different iso 8601 datetime serialization #4255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Currently some clients of my API require dates with millisecond precision and cannot handle microseconds. I achieved this by setting 'DATETIME_FORMAT' to None in the settings for DRF 3.3. Upgrading to 3.4 breaks this behavior. Is there an easy way to get the previous behavior? I can't figure out how to specify a datetime format string that gives me the ECMA-262 format. Thanks. |
@georgejlee I use a custom renderer to work around this:
Hmm, changing DEFAULT_RENDERER_CLASSES to custom renderer did not affect the rendering of my viewsets. Had to set renderer_class explicitly, strange. |
In case anyone else stumbles across this while trying to configure DRF to use a custom encoder via The reason is, the serializer field(s) (or default field renderer) will be used to format the |
Checklist
master
branch of Django REST framework.Steps to reproduce
The implementation of datetime serialization in ISO-8601 format is not consistent in the codebase.
In https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/fields.py#L1094 microseconds are included in the serialized value
In https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/utils/encoders.py#L30 only milliseconds are
Expected behavior
I would expect a consistent implementation.
Actual behavior
N/A
The text was updated successfully, but these errors were encountered: