Django: JSON Encoder Datetime Formatting Fix
Django's JSON encoder now consistently omits unnecessary ".000" microsecond suffixes from datetime and time objects. This change improves JSON output consistency and addresses a long-standing formatting inconsistency.
Duration: PT1M58S
Episode overview
This episode is a short developer briefing from Django.
It explains recent repository work in plain language.
- Show: Django
- Published: 2026-06-01T13:01:56Z
- Audio duration: PT1M58S
Transcript excerpt
This excerpt keeps the crawler page concise. Listen to the episode or use the RSS feed for the full update.
Good morning. This is your Django developer briefing for June 1st, 2026.
Today's activity centers on a focused improvement to Django's JSON serialization behavior. The framework now handles datetime formatting more consistently when converting objects to JSON.
The main change addresses how Django's JSON encoder handles datetime and time objects with zero microseconds. Previously, the encoder would inconsistently include or omit the ".000" fractional second suffix, creating unpredictable JSON output. Pull request 21340 from SnippyCodes resolves this by making the encoder…
The implementation uses a time specification parameter set to milliseconds, then strips the resulting ".000" string when present. This approach ensures that datetime objects like "2026-06-01T08:34:00" appear without the trailing ".000" in JSON output, while preserving actual microsecond data when it exists.
This change impacts any Django application that serializes datetime or time objects to JSON, particularly APIs and data export functionality. The fix improves output consistency and reduces JSON payload size slightly, while maintaining backward compatibility for consumers that can handle either format.
The pull…
Nearby episodes from Django
- Model and Infrastructure Fixes
- Database Performance and Security Hardening
- Security Patch Release and Translation Updates
- Error Handling and Developer Tools
- Weekly Recap - Security Hardening & Documentation Polish
- Documentation Updates and CI Fixes
- Authentication Updates and Documentation Improvements
- Documentation Cleanup and Infrastructure Updates