Review
DRF default DateTime fields format is 'iso-8601'. It uses python datetime.isoformat under the hood and results in optional milliseconds.
You can use DRF DATETIME_FORMAT settings to override format string for all your DateTime fields. Another option is DateTimeField subclass with to_representation method defined. We use datetime.isoformat(timespec='microseconds') here.
It also seems a good idea to subclass ModelSerializer and replace mapping of Django Fields to your class in serializer_field_mapping.
0 views0
Comments