Join us Sept 17 at .local NYC! Use code WEB50 to save 50% on tickets. Learn more >
MongoDB Event
Docs Menu
Docs Home
/ / /
Django MongoDB Backend

Django and MongoDB Feature Compatibility

On this page, you can find information about supported and unsupported features in Django MongoDB Backend. You can also find features currently planned for future releases. We will prioritize these upcoming features based on user demand, and you can request support for a feature by creating a JIRA issue.

Django MongoDB Backend supports the following operations, but they might be less performant:

Operation
Performance Notes

$expr operations

Queries that use the $expr operator might run slowly, since this operator often cannot predict which index to use and performs a collection scan. Some QuerySet operations, such as queries that specify an in lookup, use $expr to evaluate the query results and experience degraded performance.
We plan to address this performance issue in a post-GA release.

$lookup operations

Queries that use the $lookup operator might run slowly. To improve performance, we recommend that you use embedded models instead of the $lookup operator when possible. To learn more about how to reduce $lookup operations, see the Reduce $lookup Operations guide in the MongoDB Atlas documentation.

This section indicates whether Django MongoDB Backend supports various MongoDB features.

MongoDB Feature
Current Support

Atlas Search indexes

Partially Supported. You can use Django MongoDB Backend to create basic Atlas Search indexes that specify an index name and the fields to index. All other index definition fields are unsupported.

MongoDB does not support Atlas Search indexes on some data types. To view a list of unsupported types, see Data Type Limitations in the MongoDB Atlas documentation.

Atlas Vector Search indexes

Partially Supported. You can use Django MongoDB Backend to create basic Atlas Vector Search indexes that specify an index name, the fields to index, and a similarity function. All other index definition fields are unsupported.

Compound indexes

Embedded document indexes

Geospatial indexes

Multikey indexes

Partial indexes

Single field indexes

Unique indexes

Updating embedded model indexes after model creation

Unsupported.

EmbeddedModelArrayField indexes

PolymorphicEmbeddedModelField and PolymorphicEmbeddedModelArrayField indexes

Unsupported.

Django MongoDB Backend currently supports all MongoDB data types not included in the following table. To view a full list of supported types, see the MongoDB BSON Fields section of the Create Models guide.

BSON Data Type
Current Support

Object

You can use embedded models and polymorphic embedded models to represent objects. If you are using the EmbeddedModelField field, the following limitations apply: - Foreign key fields are not supported. - Arbitrary or untyped embedded model fields are not supported. You must derive all fields from an EmbeddedModel class.

Regular Expression

Unsupported. However, we plan to support this type in a post-GA release.

MongoDB Feature
Current Support

Aggregation operations

Partially Supported. The Django MongoDB Backend does not include custom Django field lookups for the MongoDB aggregation framework, but you can use the raw_aggregate() method.

Atlas Search queries

Delete operations

Geospatial queries

Use the raw_aggregate() method to run geospatial queries instead of the GIS QuerySet API.

Insert operations

Read operations

Update operations

Vector Search queries

MongoDB Feature
Current Support

Asynchronous support

Authentication

Cached data storage

Unsupported. However, we plan to add support for this feature in a post-GA release.

Change Streams

Unsupported. However, we plan to add support for this feature in a post-GA release.

Client-side Field Level Encryption and Queryable Encryption

Unsupported. However, we plan to add support for this feature in a post-GA release.

Collection interaction

Database interaction

GridFS

Unsupported. However, we plan to add support for this feature in a post-GA release.

Multiple models for one collection

Unsupported.

Representing documents

Use models to represent MongoDB documents.

Schema validation

Unsupported. However, we plan to add support for this feature in a post-GA release.

Timeseries data

Transactions

You can use Django MongoDB Backend's custom transactions API with the following limitations: - QuerySet.union() is not supported within a transaction. - Savepoints, or nested atomic blocks, are not supported. The outermost atomic block starts a transaction, and any subsequent atomic blocks have no effect. - Your MongoDB deployment must be a replica set or sharded cluster.

This section indicates whether the Django MongoDB Backend supports various Django features.

Django MongoDB Backend currently supports all Django fields not included in the following table. To view a full list of supported fields, see the Django Fields section of the Create Models guide.

Django Field Type
Current Support

AutoField

Unsupported. The BigAutoField and SmallAutoField types are also not supported. Instead, use ObjectIdField.

CompositePrimaryKey

Unsupported.

DateTimeField

Microsecond granularity for DateTimeField values is not supported.

DurationField

DurationField stores milliseconds rather than microseconds.

ForeignKey

Partially Supported. You can use this field type with the following limitations:

  • When possible, you should use an EmbeddedModelField instead of a ForeignKey field to avoid using $lookup operations. An EmbeddedModelField emulates a MongoDB embedded document and performs better than a ForeignKey field. To learn more about how to reduce $lookup operations, see the Reduce $lookup Operations guide in the Atlas documentation.

  • Performance of CASCADE deletes on a ForeignKey field is not as performant as using an EmbeddedModelField.

GeneratedField

Unsupported.

JSONField

Partially Supported. You can use this field type with the following limitations:

  • Django MongoDB Backend cannot distinguish between a JSON and a SQL null value. Queries that use Value(None, JSONField()) or the isnull lookup return both JSON and SQL null values.

  • Some queries with Q objects, such as Q(value__foo="bar"), might not work as expected.

  • Filtering for None values incorrectly returns objects in which a field does not exist.

Django MongoDB Backend currently supports all Django QuerySet methods not included in the following table. To view the supported methods, see QuerySet API in the Django documentation.

Django QuerySet Feature
Current Support

delete()

You cannot use this method to perform queries that span multiple collections.

extra()

Unsupported.

Pattern-matching lookups

You can only use these lookups to query string fields.
The pattern-matching lookups are iexact, startswith, istartswith, endswith, iendswith, contains, icontains, regex, and iregex

prefetch_related()

Unsupported.

raw()

Unsupported. However, you can use the raw_aggregate() method to run queries that use MongoDB's aggregation pipeline syntax.

update()

You cannot use this method to perform queries that span multiple collections.

Django MongoDB Backend currently supports all database functions not included in the following table. To view a full list of functions, see Database Functions in the Django documentation.

Django Function
Current Support

Chr

Unsupported.

ExtractQuarter

Unsupported.

MD5

Unsupported.

Now

Unsupported.

Ord

Unsupported.

Pad

Unsupported.

Repeat

Unsupported.

Reverse

Unsupported.

Right

Unsupported.

SHA1, SHA224, SHA256, SHA384, SHA512

Unsupported.

Sign

Unsupported.

Trunc

Partially Supported. The tzinfo parameter of the TruncDate and TruncTime database functions is not supported.

Django Feature
Current Support

Django Admin

Django Authentication

GeoDjango

Partially Supported. This web framework is supported with the following limitations:

  • The GIS QuerySet API is not supported.

  • MongoDB does not support any spatial reference system identifiers other than 4326.

  • RasterField is not supported.

Django MongoDB Backend supports Django forms, but PolymorphicEmbeddedModelField and PolymorphicEmbeddedModelArrayField do not appear in forms.

Django MongoDB Backend currently supports all management commands not included in the following table. To view a full list of commands, see Available commands in the Django documentation.

Django Command
Current Support

createcachetable

Unsupported.

dumpdata

Unsupported. However, we plan to add support for this feature in a post-GA release.

inspectdb

Unsupported. However, we plan to add support for this feature in a post-GA release.

loaddata

Unsupported. However, we plan to add support for this feature in a post-GA release.

Django Feature
Current Support

Creating, deleting, and updating indexes through migration commands

Partially Supported. You cannot update indexes on embedded model or array fields.

Unsupported.

migrate --fake-initial option

Unsupported.

Migrations for embedded models

Partially Supported. Migration commands do not detect changes to embedded model fields or embedded models referenced by a PolymorphicEmbeddedModelField or PolymorphicEmbeddedModelArrayField.

Library
Current Support

Partially Supported. To learn more about the use cases and limitations of this library, see Django filter in the Django MongoDB CLI documentation.

Partially Supported. To learn more about the use cases and limitations of this library, see Django rest framework in the Django MongoDB CLI documentation.

Partially Supported. To learn more about the use cases and limitations of this library, see Django allauth in the Django MongoDB CLI documentation.

Partially Supported. To learn more about the use cases and limitations of this library, see Django debug toolbar in the Django MongoDB CLI documentation.

Back

Transactions

On this page