Overview
在此页面上,您可以找到有关 Django MongoDB后端支持和不支持的功能的信息。您还可以找到当前计划在未来版本中提供的功能。我们将根据用户需求对这些即将推出的功能进行优先级排序,您可以通过 创建 JIRA 问题 请求对某项功能的支持。
性能限制
Django MongoDB后端支持以下操作,但性能可能较低:
操作 | 性能说明 |
---|---|
| 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. |
| 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. |
MongoDB功能
本部分指示 Django MongoDB后端是否支持各种MongoDB功能。
索引支持
MongoDB功能 | 当前支持 |
---|---|
Atlas Search 索引 | 部分支持。您可以使用 Django MongoDB后端创建基本的Atlas Search索引,并指定索引名称和要索引的字段。不支持所有其他索引定义字段。 MongoDB不支持某些数据类型的Atlas Search索引。要查看不支持的类型列表,请参阅MongoDB Atlas文档中的数据类型限制。 |
Atlas Vector Search 索引 | |
复合索引 | ✓ |
嵌入式文档索引 | ✓ |
地理空间索引 | ✓ |
多键索引 | ✓ |
部分索引 | ✓ |
单字段索引 | ✓ |
Unique indexes | ✓ |
创建模型后更新嵌入式模型索引 | 不支持。 |
| ✓ |
| 不支持。 |
数据类型支持
Django MongoDB后端当前支持下表中未包含的所有MongoDB数据类型。要查看支持类型的完整列表,请参阅创建模型指南的MongoDB BSON字段部分。
BSON 数据类型 | 当前支持 |
---|---|
| ✓ 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. |
| 不支持。不过,我们计划在正式发布后的版本中支持这种类型。 |
查询支持
MongoDB功能 | 当前支持 |
---|---|
聚合操作 | 部分支持。Django MongoDB后端不包括MongoDB聚合框架的自定义 Django字段查找,但您可以使用 raw_aggregate() 方法。 |
Atlas Search 查询 | ✓ |
删除操作 | ✓ |
地理空间查询 | ✓ Use the raw_aggregate() method
to run geospatial queries instead of the GIS QuerySet API. |
插入操作 | ✓ |
读取操作 | ✓ |
更新操作 | ✓ |
向量搜索查询 | ✓ |
数据库和集合支持
MongoDB功能 | 当前支持 |
---|---|
异步支持 | ✓ |
身份验证 | ✓ |
缓存数据存储 | 不支持。不过,我们计划在正式发布后的版本中添加对此功能的支持。 |
Change Streams | 不支持。不过,我们计划在正式发布后的版本中添加对此功能的支持。 |
客户端字段级加密和Queryable Encryption | 不支持。不过,我们计划在正式发布后的版本中添加对此功能的支持。 |
集合交互 | ✓ |
数据库交互 | ✓ |
GridFS | 不支持。不过,我们计划在正式发布后的版本中添加对此功能的支持。 |
一个集合有多个模型 | 不支持。 |
表示文档 | ✓ Use models to represent MongoDB documents. |
模式验证 | 不支持。不过,我们计划在正式发布后的版本中添加对此功能的支持。 |
时间序列数据 | ✓ |
事务 | ✓ 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. |
Django 功能
本部分指示 Django MongoDB后端是否支持各种 Django 功能。
现场支持
Django MongoDB后端目前支持下表中未包含的所有 Django 字段。要查看支持字段的完整列表,请参阅“创建模型”指南的 Django 字段 部分。
Django 字段类型 | 当前支持 |
---|---|
| 不支持。也不支持 |
| 不支持。 |
| ✓ Microsecond granularity for DateTimeField values is not supported. |
| ✓ DurationField stores milliseconds rather than microseconds. |
| 部分支持。您可以使用此字段类型,但有以下限制:
|
| 不支持。 |
| 部分支持。您可以使用此字段类型,但有以下限制:
|
查询支持
Django MongoDB后端目前支持下表中未包含的所有 Django QuerySet
方法。要查看支持的方法,请参阅 Django 文档中的QuerySet API。
Django QuerySet 功能 | 当前支持 |
---|---|
| ✓ You cannot use this method to perform
queries that span multiple collections. |
| 不支持。 |
模式匹配查找 | ✓ 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 |
| 不支持。 |
| 不支持。但是,您可以使用 |
| ✓ You cannot use this method to perform
queries that span multiple collections. |
数据库函数支持
Django MongoDB后端当前支持下表中未包含的所有数据库函数。要查看函数的完整列表,请参阅 Django 文档中的数据库函数。
Contrib 应用支持
Django 功能 | 当前支持 |
---|---|
Django Admin | ✓ |
Django 身份验证 | ✓ |
GeoDjango | 部分支持。此 Web框架受支持但有以下限制:
|
表单支持
Django MongoDB后端支持 Django 表单,但 PolymorphicEmbeddedModelField
和 PolymorphicEmbeddedModelArrayField
不会出现在表单中。
管理命令支持
Django MongoDB后端当前支持下表中未包含的所有管理命令。要查看命令的完整列表,请参阅 Django 文档中的可用命令。
Django 命令 | 当前支持 |
---|---|
| 不支持。 |
| 不支持。不过,我们计划在正式发布后的版本中添加对此功能的支持。 |
| 不支持。不过,我们计划在正式发布后的版本中添加对此功能的支持。 |
| 不支持。不过,我们计划在正式发布后的版本中添加对此功能的支持。 |
迁移支持
Django 功能 | 当前支持 |
---|---|
通过迁移命令创建、删除和更新索引 | 部分支持。您无法更新嵌入式模型或大量字段上的索引。 |
不支持。 | |
| 不支持。 |
嵌入式模型的迁移 | 部分支持。迁移命令不会检测对 |
第三方库支持
库 | 当前支持 |
---|---|
部分支持。要学习;了解有关此库的使用案例和限制的更多信息,请参阅 Django MongoDB CLI文档中的 Django过滤。 | |
部分支持。要学习;了解有关此库的使用案例和限制的更多信息,请参阅 Django MongoDB CLI文档中的 Django allauth。 | |