|
| 1 | +.. _django-limitations: |
| 2 | + |
| 3 | +============ |
| 4 | +Limitations |
| 5 | +============ |
| 6 | + |
| 7 | +.. contents:: On this page |
| 8 | + :local: |
| 9 | + :backlinks: none |
| 10 | + :depth: 1 |
| 11 | + :class: singlecol |
| 12 | + |
| 13 | +.. facet:: |
| 14 | + :name: genre |
| 15 | + :values: reference |
| 16 | + |
| 17 | +.. meta:: |
| 18 | + :keywords: support, features, django |
| 19 | + |
| 20 | +Overview |
| 21 | +-------- |
| 22 | + |
| 23 | +On this page, you can find a list of features that |
| 24 | +{+django-odm+} does not support. Because {+django-odm+} is in active |
| 25 | +development, some features listed on this page might be considered for future |
| 26 | +releases based on user demand. You can request support for a feature by leaving |
| 27 | +a suggestion on the `Drivers Feedback Forum |
| 28 | +<https://feedback.mongodb.com/forums/924286-drivers?category_id=370732>`__. |
| 29 | + |
| 30 | +Unsupported Database Variables |
| 31 | +------------------------------ |
| 32 | + |
| 33 | +The following database variables are not supported by {+django-odm+}: |
| 34 | + |
| 35 | +- ``ATOMIC_REQUESTS`` |
| 36 | +- ``AUTOCOMMIT`` |
| 37 | +- ``CONN_HEALTH_CHECKS`` |
| 38 | +- ``TIME_ZONE`` |
| 39 | + |
| 40 | +Model Limitations |
| 41 | +----------------- |
| 42 | + |
| 43 | +The following limitations apply to models in {+django-odm+}: |
| 44 | + |
| 45 | +- {+django-odm+} enforces a one-to-one mapping between a Django model and a |
| 46 | + MongoDB collection. Because of this, multiple models cannot share the same collection. |
| 47 | + |
| 48 | +Indexes |
| 49 | +~~~~~~~ |
| 50 | + |
| 51 | +{+django-odm+} does not support the following index functionalities: |
| 52 | + |
| 53 | +- Creating ``$vectorSearch`` and ``$search`` indexes through the Django |
| 54 | + Indexes API |
| 55 | +- Creating geospatial indexes through the Django Indexes API |
| 56 | +- Updating indexes in ``EmbeddedModelFields`` after model creation |
| 57 | + |
| 58 | +To learn how to run unsupported database operations by operating directly on |
| 59 | +your ``MongoClient`` instance, see :ref:`django-client-operations` in the |
| 60 | +Perform Raw Database Queries guide. |
| 61 | + |
| 62 | +Fields |
| 63 | +~~~~~~ |
| 64 | + |
| 65 | +{+django-odm+} has the following limitations on the specified field types: |
| 66 | + |
| 67 | +- ``ArrayField`` |
| 68 | + |
| 69 | + - {+django-odm+} does not support ``ArrayField`` polymorphism. |
| 70 | + - {+django-odm+} does not support nesting an ``EmbeddedModelField`` within an ``ArrayField``. |
| 71 | + |
| 72 | +- ``EmbeddedModelField`` |
| 73 | + |
| 74 | + - ``EmbeddedModel`` schema changes do not register after creation. |
| 75 | + - Embedded documents cannot take Django foreign keys. |
| 76 | + - {+django-odm+} does not support arbitrary or untyped embedded model |
| 77 | + fields. You must derive all fields from a ``EmbeddedModel`` class. |
| 78 | + |
| 79 | +- ``JSONField`` |
| 80 | + |
| 81 | + - {+django-odm+} cannot distinguish between a JSON and a SQL ``null`` value. |
| 82 | + Queries that use ``Value(None, JSONField())`` or the ``isnull`` lookup |
| 83 | + return both JSON and SQL ``null`` values. |
| 84 | + - Some queries with ``Q`` objects, such as ``Q(value__foo="bar")``, might |
| 85 | + not work as expected. |
| 86 | + - Filtering for ``None`` values incorrectly returns objects in which a field |
| 87 | + does not exist. |
| 88 | + |
| 89 | +- ``DateTimeField`` |
| 90 | + |
| 91 | + - {+django-odm+} does not support microsecond granularity for |
| 92 | + ``DateTimeField``. |
| 93 | + |
| 94 | +- ``DurationField`` |
| 95 | + |
| 96 | + - ``DurationField`` stores milliseconds rather than microseconds. |
| 97 | + |
| 98 | +- ``ForeignKey`` |
| 99 | + |
| 100 | + - When possible, you should use an ``EmbeddedModelField`` instead of a |
| 101 | + ``ForeignKey`` field to avoid using ``$lookup`` operations. An |
| 102 | + ``EmbeddedModelField`` emulates a MongoDB embedded document and performs |
| 103 | + better than a ``ForeignKey`` field. To learn more about how to reduce |
| 104 | + ``$lookup`` operations, see the :atlas:`Reduce $lookup Operations |
| 105 | + </schema-suggestions/reduce-lookup-operations/>` guide in the Atlas |
| 106 | + documentation. |
| 107 | + - Performance of `CASCADE deletes <{+django-docs+}/ref/models/fields/#django.db.models.CASCADE>`__ |
| 108 | + on a ``ForeignKey`` field is not as performant as using an |
| 109 | + ``EmbeddedModelField``. |
| 110 | + |
| 111 | +The following field types are unavailable in {+django-odm+}: |
| 112 | + |
| 113 | +- ``GeneratedField`` |
| 114 | +- ``AutoField`` |
| 115 | +- ``BigAutoField`` |
| 116 | +- ``SmallAutoField`` |
| 117 | + |
| 118 | +Querying Limitations |
| 119 | +-------------------- |
| 120 | + |
| 121 | +{+django-odm+} does not support the following ``QuerySet`` API methods: |
| 122 | + |
| 123 | +- ``distinct()`` |
| 124 | +- ``dates()`` |
| 125 | +- ``datetimes()`` |
| 126 | +- ``prefetch_related()`` |
| 127 | +- ``extra()`` |
| 128 | + |
| 129 | +{+django-odm+} does not support ``QuerySet.delete()`` and ``update()`` queries |
| 130 | +that span multiple collections. |
| 131 | + |
| 132 | +Geospatial Queries |
| 133 | +~~~~~~~~~~~~~~~~~~ |
| 134 | + |
| 135 | +- {+django-odm+} does not support ``GeoDjango``. |
| 136 | +- {+django-odm+} does not have any Django lookup operators for MongoDB-specific |
| 137 | + geospatial queries. |
| 138 | + |
| 139 | +Aggregation Operators |
| 140 | +~~~~~~~~~~~~~~~~~~~~~ |
| 141 | + |
| 142 | +{+django-odm+} does not contain any custom Django field lookups for the MongoDB |
| 143 | +aggregation framework. Instead, use the ``raw_aggregate()`` method. For more |
| 144 | +information on the ``raw_aggregate()`` method, see |
| 145 | +the :ref:`django-raw-queries` guide. |
| 146 | + |
| 147 | +.. TODO: Link to aggregation |
| 148 | + |
| 149 | +Database Functions |
| 150 | +~~~~~~~~~~~~~~~~~~ |
| 151 | + |
| 152 | +{+django-odm+} does not support the following database functions: |
| 153 | + |
| 154 | +- ``Chr`` |
| 155 | +- ``ExtractQuarter`` |
| 156 | +- ``MD5`` |
| 157 | +- ``Now`` |
| 158 | +- ``Ord`` |
| 159 | +- ``Pad`` |
| 160 | +- ``Repeat`` |
| 161 | +- ``Reverse`` |
| 162 | +- ``Right`` |
| 163 | +- ``SHA1``, ``SHA224``, ``SHA256``, ``SHA384``, ``SHA512`` |
| 164 | +- ``Sign`` |
| 165 | + |
| 166 | +The ``tzinfo`` parameter of the ``Trunc`` database functions doesn't work |
| 167 | +properly because MongoDB converts the result back to UTC. |
| 168 | + |
| 169 | +Django Management Command Limitations |
| 170 | +------------------------------------- |
| 171 | + |
| 172 | +{+django-odm+} does not support the following Django management commands: |
| 173 | + |
| 174 | +- ``createcachetable`` |
| 175 | +- ``inspectdb`` |
| 176 | +- ``optimizemigration`` |
| 177 | +- ``sqlflush`` |
| 178 | +- ``sqlsequencereset`` |
| 179 | + |
| 180 | +Migration Limitations |
| 181 | +--------------------- |
| 182 | + |
| 183 | +- {+django-odm+} does not support enforced schema validation. To learn how to |
| 184 | + enforce schema validation in your application, see the :manual:`Specify JSON |
| 185 | + Schema Validation </core/schema-validation/specify-json-schema/>` guide in the |
| 186 | + {+mdb-server+} manual. |
| 187 | +- {+django-odm+} does not support `DDL Transactions |
| 188 | + <{+django-docs+}/topics/migrations/#transactions>`__. |
| 189 | +- {+django-odm+} does not support the ``migrate --fake-initial`` command. |
| 190 | + |
| 191 | +Asynchronous Support |
| 192 | +-------------------- |
| 193 | + |
| 194 | +{+django-odm+} has not been tested for support of the asynchronous functionality of |
| 195 | +the Django API. |
| 196 | + |
| 197 | +Data Types |
| 198 | +---------- |
| 199 | + |
| 200 | +{+django-odm+} does not have a custom ``Field`` class for the ``BSONRegExp`` |
| 201 | +data type. Instead, use the ``CharField`` class. |
| 202 | + |
| 203 | +Performance |
| 204 | +----------- |
| 205 | + |
| 206 | +The engineering team is prioritizing feature development for the Public Preview |
| 207 | +release of {+django-odm+}. Because of this, you might notice performance |
| 208 | +limitations with certain workloads. If you encounter any performance issues, |
| 209 | +please report them as shown in the :ref:`Issues & Help <django-issues-and-help>` |
| 210 | +guide. You can also share your feedback on the `Drivers Feedback Forum |
| 211 | +<https://feedback.mongodb.com/forums/924286-drivers?category_id=370732>`__. |
0 commit comments