We’re happy to announce the release of Django MongoDB Backend 6.0.4. This release adds a number of new query features, several bug fixes, and a few backwards-incompatible changes to be aware of. Here are the highlights.
New features
- Window functions are now supported.
StringAggaggregate is now supported (it was unsupported in 6.0.0).- New database functions:
ExtractQuarter,LPad,RPad,Repeat,Reverse,Right,Sign, plusMD5andSHA256(which require MongoDB 8.3+). - Timezone support: fixed-offset
tzinfoin theExtractfunctions, and thetzinfoparameter ofTruncDateandTruncTime. - Pattern-matching lookups on
UUIDField(iexact,startswith,istartswith,endswith,iendswith,contains,icontains,regex,iregex). FilteredRelationis now supported.- Vector search: a new
indexing_methodsargument onVectorSearchIndexlets you choose"hnsw"(server default) or"flat"per vector field. - Django’s warning for import-time queries is now supported.
Bug fixes
Sumnow returnsNone(instead of0) when no rows match, matching SQL semantics.- Fixed pattern-matching lookups on non-string fields.
atomic()no longer silences exceptions raised on commit.- Fixed several crashes with
EmbeddedModelField/EmbeddedModelArrayFieldform submission and validation-error rendering, and with polymorphic embedded models. makemigrationsnow correctly ordersCreateModeloperations for embedded models.- Aggregation queries no longer generate redundant accumulators in the
$groupstage. - Added debug logging for
QuerySet.explain().
Backwards-incompatible changes
A few changes may require action:
- Embedded models are now unmanaged (
managed = False). Runningmakemigrationswill add anAlterModelOptionsoperation for existing embedded models. - You must add
'django_mongodb_backend'toINSTALLED_APPSto generate migration operations for embedded models. - Unique constraints are now created so the query planner can avoid collection scans (for all built-in fields except
ArrayField,BinaryField, andJSONField). To benefit, drop and recreate constraints created with older versions.
See the full release notes for details and migration guidance: https://django-mongodb-backend.readthedocs.io/en/latest/releases/6.0.x.html
Install or upgrade with pip install --upgrade django-mongodb-backend==6.0.4.
Found a bug or have a feature request? Please file an issue in the Python Integrations (INTPYTHON) project on our public Jira: https://jira.mongodb.org/projects/INTPYTHON/
As always, feedback and bug reports are welcome. Happy building!