Django MongoDB Backend 6.0.x¶
6.0.4¶
July 14, 2026
New features¶
Added support for window functions.
Added support for the following database functions:
Added support for the
StringAggaggregate.Added support for fixed-offset
tzinfoin theExtractdatabase functions.Added support for the
tzinfoparameter of theTruncDateandTruncTimedatabase functions.Added support for Django’s warning when performing import-time queries.
Added support for pattern matching lookups (
iexact,startswith,istartswith,endswith,iendswith,contains,icontains,regex, andiregex) onUUIDField.Added support for
FilteredRelation.Added the
indexing_methodskeyword argument toVectorSearchIndex, 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
atomic()from silencing exceptions raised on commit.Added debug logging of
QuerySet.explain()queries.Fixed crash when saving a model with
PolymorphicEmbeddedModelFieldorPolymorphicEmbeddedModelArrayFieldthat specifiesembedded_modelsas a list of concrete models.Fixed queries for pattern matching lookups (
iexact,startswith,istartswith,endswith,iendswith,contains,icontains,regex, andiregex) on non-string fields.Fixed form rendering of
EmbeddedModelFieldandEmbeddedModelArrayFieldso 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
EmbeddedModelFieldto a model with aEmbeddedModelArrayField.Prevented aggregation queries from generating redundant accumulators in the
$groupstage.Made the
Sumaggregation function returnNoneinstead of0when no rows match, matching SQL semantics.Made
makemigrationscorrectly orderCreateModeloperations for embedded models. If embedded models aren’t created before models that reference them,migratecrashes withAttributeError: 'str' object has no attribute '_meta'.
Backwards incompatible changes¶
Subclasses of
EmbeddedModelare now treated as unmanaged, that is they have themanagedMetaoption set toFalse.Existing embedded models will have an
AlterModelOptionsmigration operation added when you runmakemigrations. Alternatively, you can edit your migrations and add'managed': Falseto each model’sCreateModeloperation under'abstract': False:operations = [ migrations.CreateModel( name="...", fields=[...], options={ "abstract": False, "managed": False, }, ), ..., ]
You must include
'django_mongodb_backend'in theINSTALLED_APPSsetting 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
ArrayField,BinaryField, andJSONField. 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 polymorphic subfield support to
EmbeddedFieldIndexandEmbeddedFieldUniqueConstraint.See Indexing PolymorphicEmbeddedModelField, Unique constraints on PolymorphicEmbeddedModelField, Indexing PolymorphicEmbeddedModelArrayField, and Unique constraints on PolymorphicEmbeddedModelArrayField.
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
makemigrationsserialize embedded model references as strings so that references in migrations don’t need to be adjusted if models are later removed.Added a helpful
NotSupportedErrorforQuerySet.extra(where=...)andStringAgg(..., 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, andMeta.unique_togetheris deprecated in favor of usingEmbeddedFieldIndexandEmbeddedFieldUniqueConstrainton the top-level model. See Inline constraints and indexes on embedded models for an example.
6.0.2¶
February 5, 2026
New features¶
Added support for
QuerySet.intersection()anddifference().Added support for
UniqueConstraint.nulls_distinct. See Unique constraints for MongoDB-specific details.Added
EmbeddedFieldIndexandEmbeddedFieldUniqueConstraintto index and create unique constraints on subfields ofEmbeddedModelFieldandEmbeddedModelArrayField.See Indexing EmbeddedModelField, Unique constraints on EmbeddedModelField, Indexing EmbeddedModelArrayField, and Unique constraints on EmbeddedModelArrayField.
Bug fixes¶
Fixed
Model.save()crash on existing models when using Queryable Encryption.
6.0.1¶
January 22, 2026
New features¶
Added support for Queryable Encryption.
Added support for spatial lookups.
Bug fixes¶
Prevented
Indexsystem checks from running twice.Added exception messages to
DatabaseErrorandIntegrityError.Fixed
QuerySet.defer()andonly()so that they project the correct fields. Previously, they had no effect.
Performance improvements¶
Removed usage of
$facetfrom aggregate queries.
6.0.0¶
December 11, 2025
Initial release from the state of django-mongodb-backend 5.2.3.
Regarding new features in Django 6.0, the django.db.models.StringAgg
function isn’t supported.
Backwards incompatible changes¶
django_mongodb_backend.utils.parse_uri()is removed as per the deprecation timeline.The minimum supported version of MongoDB is increased from 6.0 to 7.0.