============================ Django MongoDB Backend 6.0.x ============================ .. _django-mongodb-backend-6.0.4: 6.0.4 ===== *July 14, 2026* New features ------------ - Added support for :ref:`window functions `. - Added support for the following database functions: - :class:`~django.db.models.functions.ExtractQuarter` - :class:`~django.db.models.functions.LPad`, :class:`~django.db.models.functions.RPad` - :class:`~django.db.models.functions.MD5` (requires MongoDB 8.3+) - :class:`~django.db.models.functions.Repeat` - :class:`~django.db.models.functions.Reverse` - :class:`~django.db.models.functions.Right` - :class:`~django.db.models.functions.SHA256` (requires MongoDB 8.3+) - :class:`~django.db.models.functions.Sign` - Added support for the :class:`~django.db.models.StringAgg` aggregate. - Added support for fixed-offset ``tzinfo`` in the :class:`~django.db.models.functions.Extract` database functions. - Added support for the ``tzinfo`` parameter of the :class:`~django.db.models.functions.TruncDate` and :class:`~django.db.models.functions.TruncTime` database functions. - Added support for Django's warning when performing import-time queries. - Added support for pattern matching lookups (:lookup:`iexact`, :lookup:`startswith`, :lookup:`istartswith`, :lookup:`endswith`, :lookup:`iendswith`, :lookup:`contains`, :lookup:`icontains`, :lookup:`regex`, and :lookup:`iregex`) on :class:`~django.db.models.UUIDField`. - Added support for :class:`~django.db.models.FilteredRelation`. - Added the ``indexing_methods`` keyword argument to :class:`~django_mongodb_backend.indexes.VectorSearchIndex`, which allows specifying ``"hnsw"`` (server default) or ``"flat"`` for each vector field. Bug fixes --------- - Made creating models with expressions raise a helpful error message. - Prevented :func:`~django_mongodb_backend.transaction.atomic` from silencing exceptions raised on commit. - Added debug logging of ``QuerySet.explain()`` queries. - Fixed crash when saving a model with :class:`~django_mongodb_backend.fields.PolymorphicEmbeddedModelField` or :class:`~django_mongodb_backend.fields.PolymorphicEmbeddedModelArrayField` that specifies ``embedded_models`` as a list of concrete models. - Fixed queries for pattern matching lookups (:lookup:`iexact`, :lookup:`startswith`, :lookup:`istartswith`, :lookup:`endswith`, :lookup:`iendswith`, :lookup:`contains`, :lookup:`icontains`, :lookup:`regex`, and :lookup:`iregex`) on non-string fields. - Fixed form rendering of :class:`~django_mongodb_backend.fields.EmbeddedModelField` and :class:`~django_mongodb_backend.fields.EmbeddedModelArrayField` so that a validation error is shown next to the subfield that caused it rather than being repeated on the parent field. - Fixed crash when submitting a form that has an :class:`~django_mongodb_backend.fields.EmbeddedModelField` to a model with a :class:`~django_mongodb_backend.fields.EmbeddedModelArrayField`. - Prevented aggregation queries from generating redundant accumulators in the ``$group`` stage. - Made the :class:`~django.db.models.Sum` aggregation function return ``None`` instead of ``0`` when no rows match, matching SQL semantics. - Made ``makemigrations`` correctly order ``CreateModel`` operations for embedded models. If embedded models aren't created before models that reference them, ``migrate`` crashes with ``AttributeError: 'str' object has no attribute '_meta'``. Backwards incompatible changes ------------------------------ - Subclasses of :class:`~django_mongodb_backend.models.EmbeddedModel` are now treated as unmanaged, that is they have the :attr:`~django.db.models.Options.managed` ``Meta`` option set to ``False``. Existing embedded models will have an ``AlterModelOptions`` migration operation added when you run :djadmin:`makemigrations`. Alternatively, you can edit your migrations and add ``'managed': False`` to each model's ``CreateModel`` operation under ``'abstract': False``: .. code-block:: python :emphasize-lines: 7 operations = [ migrations.CreateModel( name="...", fields=[...], options={ "abstract": False, "managed": False, }, ), ..., ] - You must include ``'django_mongodb_backend'`` in the :setting:`INSTALLED_APPS` setting in order to generate migration operations for embedded models. - Unique constraints are now created in a way that allows the MongoDB query planner to avoid a collection scan for queries of all built-in fields except :class:`~django_mongodb_backend.fields.ArrayField`, :class:`~django.db.models.BinaryField`, and :class:`~django.db.models.JSONField`. You'll have to drop and recreate constraints created using older versions of Django MongoDB Backend if you want to take advantage of this. 6.0.3 ===== *April 2, 2026* New features ------------ - Added :ref:`support for matching ObjectIDs in URL patterns `. - Added polymorphic subfield support to :class:`~django_mongodb_backend.indexes.EmbeddedFieldIndex` and :class:`~django_mongodb_backend.constraints.EmbeddedFieldUniqueConstraint`. See :ref:`polymorphic-embedded-model-field-indexes`, :ref:`polymorphic-embedded-model-field-unique-constraints`, :ref:`polymorphic-embedded-model-array-field-indexes`, and :ref:`polymorphic-embedded-model-array-field-unique-constraints`. - ``str(queryset.query)`` now outputs MQL instead of SQL. Bug fixes --------- - Made model saving raise an exception to prevent a misconfiguration from resulting in the creation of models with encrypted fields in non-encrypted databases. - Made ``makemigrations`` serialize embedded model references as strings so that references in migrations don't need to be adjusted if models are later removed. - Added a helpful ``NotSupportedError`` for ``QuerySet.extra(where=...)`` and ``StringAgg(..., distinct=True)`` rather than crashing with more obscure exceptions. Deprecated features ------------------- - Defining indexes and constraints on embedded models using ``unique=True``, ``db_index=True``, ``Meta.constraints``, ``Meta.indexes``, and ``Meta.unique_together`` is deprecated in favor of using :class:`~django_mongodb_backend.indexes.EmbeddedFieldIndex` and :class:`~django_mongodb_backend.constraints.EmbeddedFieldUniqueConstraint` on the top-level model. See :ref:`inline-constraints-and-indexes-deprecation` for an example. 6.0.2 ===== *February 5, 2026* New features ------------ - Added support for :meth:`QuerySet.intersection() ` and :meth:`~django.db.models.query.QuerySet.difference`. - Added support for :attr:`UniqueConstraint.nulls_distinct `. See :ref:`unique-constraints` for MongoDB-specific details. - Added :class:`~django_mongodb_backend.indexes.EmbeddedFieldIndex` and :class:`~django_mongodb_backend.constraints.EmbeddedFieldUniqueConstraint` to index and create unique constraints on subfields of :class:`~.fields.EmbeddedModelField` and :class:`~.fields.EmbeddedModelArrayField`. See :ref:`embedded-model-field-indexes`, :ref:`embedded-model-field-unique-constraints`, :ref:`embedded-model-array-field-indexes`, and :ref:`embedded-model-array-field-unique-constraints`. Bug fixes --------- - Fixed ``Model.save()`` crash on existing models when using Queryable Encryption. 6.0.1 ===== *January 22, 2026* New features ------------ - Added support for :doc:`Queryable Encryption `. - Added support for :ref:`spatial lookups `. Bug fixes --------- - Prevented ``Index`` system checks from running twice. - Added exception messages to :class:`~django.db.DatabaseError` and :class:`~django.db.IntegrityError`. - Fixed ``QuerySet.defer()`` and ``only()`` so that they project the correct fields. Previously, they had no effect. Performance improvements ------------------------ - Removed usage of ``$facet`` from aggregate queries. 6.0.0 ===== *December 11, 2025* Initial release from the state of :ref:`django-mongodb-backend 5.2.3 `. Regarding new features in Django 6.0, the :class:`django.db.models.StringAgg` function isn't supported. Backwards incompatible changes ------------------------------ - ``django_mongodb_backend.utils.parse_uri()`` is removed as per the :ref:`deprecation timeline `. - The minimum supported version of MongoDB is increased from 6.0 to 7.0.