Django MongoDB Backend 6.0.x

6.0.4

July 14, 2026

New features

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 PolymorphicEmbeddedModelField or PolymorphicEmbeddedModelArrayField that specifies embedded_models as a list of concrete models.

  • Fixed queries for pattern matching lookups (iexact, startswith, istartswith, endswith, iendswith, contains, icontains, regex, and iregex) on non-string fields.

  • Fixed form rendering of EmbeddedModelField and 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 EmbeddedModelField to a model with a EmbeddedModelArrayField.

  • Prevented aggregation queries from generating redundant accumulators in the $group stage.

  • Made the 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 EmbeddedModel are now treated as unmanaged, that is they have the managed Meta option set to False.

    Existing embedded models will have an AlterModelOptions migration operation added when you run makemigrations. Alternatively, you can edit your migrations and add 'managed': False to each model’s CreateModel operation under 'abstract': False:

    operations = [
        migrations.CreateModel(
            name="...",
            fields=[...],
            options={
                "abstract": False,
                "managed": False,
            },
        ),
        ...,
    ]
    
  • You must include 'django_mongodb_backend' in the 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 ArrayField, BinaryField, and 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

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

6.0.2

February 5, 2026

New features

Bug fixes

  • Fixed Model.save() crash on existing models when using Queryable Encryption.

6.0.1

January 22, 2026

New features

Bug fixes

  • Prevented Index system checks from running twice.

  • Added exception messages to DatabaseError and 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 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.