microsoft/mssql-django 1.7.2
microsoft/mssql-django
Captured source
source ↗1.7.2
Repository: microsoft/mssql-django
Tag: 1.7.2
Published: 2026-05-22T12:22:06Z
Prerelease: no
Release notes:
mssql-django 1.7.2 Release Notes (May 2026)
mssql-django 1.7.2 is a patch release that fixes timezone handling bugs and resolves a Django 4.0+ compatibility issue with .explain().
---
Bug Fixes
FIX: AttributeError on .explain() for Django 4.0+ (#409, #524)
- What changed: Django 4.0 replaced
query.explain_formatandquery.explain_optionswith a singlequery.explain_infonamedtuple. The compiler was still referencing the removed attributes, causing anAttributeErrorwhen.explain()was called (e.g., via DjangoQL in Django admin). The compiler now version-gates the attribute access:explain_info.format/.optionson Django 4.0+, falling back to the old attributes on earlier versions. A regression test was added. - Who benefits: Anyone using
.explain()or tools like DjangoQL on Django 4.0+ - Impact:
.explain()now correctly raisesNotSupportedErrorinstead of crashing withAttributeError
FIX: DATETIMEOFFSET timezone support and Now() with USE_TZ=True (#484, closes #371, closes #136)
- What changed: Two related timezone bugs were fixed:
1. handle_datetimeoffset was discarding the timezone offset bytes returned by SQL Server, returning naive datetimes from DATETIMEOFFSET columns. The function now parses the full 9-element struct (including tz_offset_hour and tz_offset_minute) and returns timezone-aware datetimes. This completes the original fix from PR #140 which accidentally dropped the offset parsing. 2. sqlserver_now() always emitted SYSDATETIME(), which returns server-local time without an offset. When USE_TZ=True and the SQL Server host was not in UTC, Django would misinterpret the local time as UTC, causing timestamps to shift. Now() now emits SYSDATETIMEOFFSET() when settings.USE_TZ=True, and SYSDATETIME() otherwise.
- Who benefits: Applications using
USE_TZ=Trueon non-UTC SQL Server hosts, and anyone withDATETIMEOFFSETcolumns - Impact:
auto_now,auto_now_add, andNow()annotations now produce correct timestamps.DATETIMEOFFSETcolumns return timezone-aware datetimes as intended.
---
Test Improvements
- Removed
returninfinallythat swallowed exceptions in test utility (#526, closes #417) - Added timezone offset tests: UTC, +05:30 (IST), -05:00 (EST), -09:30 (Marquesas), +05:45 (Nepal)
- Added
NowSQLTemplateTestsverifyingSYSDATETIMEOFFSETvsSYSDATETIMEbased onUSE_TZ - Added
ExplainRegressionTestsfor.explain()behavior
---
Version Compatibility
| Component | Supported Versions | |---|---| | Django | 3.2, 4.0, 4.1, 4.2, 5.0, 5.1, 5.2, 6.0 | | Python | 3.8 – 3.14 | | SQL Server | 2016, 2017, 2019, 2022, 2025; Azure SQL DB / Managed Instance / Microsoft Fabric | | ODBC Driver | 17 or 18 for SQL Server (v18 is the default) |
---
Breaking Changes
None. This is a fully backward-compatible patch release. The DATETIMEOFFSET fix only affects the USE_TZ=True code path where Django already expects timezone-aware datetimes.
---
Contributors
Thank you to everyone who contributed to this release!
Community Contributors:
- @trolldbois (Loïc Jaquemet) — DATETIMEOFFSET timezone support and
Now()fix (#484)
---
Full Changelog
PRs included: #524, #484, #526
Notability
notability 3.0/10Minor patch release for Django SQL Server backend.