Django MongoDB Backend 6.0.4 is now available

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.
  • StringAgg aggregate is now supported (it was unsupported in 6.0.0).
  • New database functions: ExtractQuarter, LPad, RPad, Repeat, Reverse, Right, Sign, plus MD5 and SHA256 (which require MongoDB 8.3+).
  • Timezone support: fixed-offset tzinfo in the Extract functions, and the tzinfo parameter of TruncDate and TruncTime.
  • Pattern-matching lookups on UUIDField (iexact, startswith, istartswith, endswith, iendswith, contains, icontains, regex, iregex).
  • FilteredRelation is now supported.
  • Vector search: a new indexing_methods argument on VectorSearchIndex lets you choose "hnsw" (server default) or "flat" per vector field.
  • Django’s warning for import-time queries is now supported.

Bug fixes

  • Sum now returns None (instead of 0) 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 / EmbeddedModelArrayField form submission and validation-error rendering, and with polymorphic embedded models.
  • makemigrations now correctly orders CreateModel operations for embedded models.
  • Aggregation queries no longer generate redundant accumulators in the $group stage.
  • Added debug logging for QuerySet.explain().

Backwards-incompatible changes

A few changes may require action:

  1. Embedded models are now unmanaged (managed = False). Running makemigrations will add an AlterModelOptions operation for existing embedded models.
  2. You must add 'django_mongodb_backend' to INSTALLED_APPS to generate migration operations for embedded models.
  3. Unique constraints are now created so the query planner can avoid collection scans (for all built-in fields except ArrayField, BinaryField, and JSONField). To benefit, drop and recreate constraints created with older versions.

See the full release notes for details and migration guidance: Django MongoDB Backend 6.0.x - Django MongoDB Backend 6.0.5.dev0 documentation

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!

1 Like

Nice release. The window functions, FilteredRelation support, and improved vector search options are especially useful additions for projects using Django with MongoDB. Good to see the team also addressing migration and query behavior changes clearly, since those backwards-incompatible updates can save developers some surprises during upgrades.

1 Like