@@ -168,7 +168,7 @@ The following table describes supported BSON field types and their
168
168
in this guide.
169
169
170
170
* - ``Object``
171
- - ``EmbeddedModelField``
171
+ - ``EmbeddedModelField`` or ``EmbeddedModelArrayField``
172
172
- | Stores embedded documents. To learn more about using this field
173
173
with {+django-odm+}, see the :ref:`django-models-embedded` section in this guide.
174
174
@@ -452,6 +452,36 @@ and modifies the ``Movie`` model to include the ``EmbeddedModelField``:
452
452
To learn how to query data stored in an ``EmbeddedModelField``, see
453
453
:ref:`django-query-embedded` in the Specify a Query guide.
454
454
455
+ .. _django-models-embedded-array:
456
+
457
+ Use an EmbeddedModelArrayField
458
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
459
+
460
+ You can use an ``EmbeddedModelArrayField`` to represent a MongoDB ``Object``
461
+ that stores an array of document values. Each document in the array corresponds
462
+ to a {+django-odm+} ``EmbeddedModelField`` value. To create an ``EmbeddedModelArrayField``,
463
+ use the ``EmbeddedModelArrayField()`` class constructor and pass the following arguments:
464
+
465
+ - ``embedded_model``: Specifies the model stored in each array item.
466
+
467
+ - ``max_size``: *(Optional)* Specifies the maximum size of the array.
468
+
469
+ Example
470
+ ```````
471
+
472
+ This example adds an ``EmbeddedModelArrayField`` value to the model created in
473
+ the :ref:`Define a Model example <django-models-define-ex>` in this
474
+ guide. This ``cast`` field stores an array of embedded ``Actor`` models.
475
+ The following code defines the ``Actor`` model and modifies the ``Movie`` model
476
+ to include the ``EmbeddedModelArrayField``:
477
+
478
+ .. literalinclude:: /includes/model-data/models.py
479
+ :start-after: start-embedded-array-field
480
+ :end-before: end-embedded-array-field
481
+ :language: python
482
+ :copyable:
483
+ :emphasize-lines: 5, 15
484
+
455
485
Additional Information
456
486
----------------------
457
487
0 commit comments