Skip to content

Commit 1c481ec

Browse files
committed
docs
1 parent f428385 commit 1c481ec

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

docs/source/ref/models/fields.rst

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ Some MongoDB-specific fields are available in ``django_mongodb_backend.fields``.
3535
:class:`~django.db.models.OneToOneField` and
3636
:class:`~django.db.models.ManyToManyField`) and file fields (
3737
:class:`~django.db.models.FileField` and
38-
:class:`~django.db.models.ImageField`). :class:`EmbeddedModelField` is
39-
also not (yet) supported.
38+
:class:`~django.db.models.ImageField`).
39+
40+
For :class:`EmbeddedModelField`, use :class:`EmbeddedModelArrayField`.
4041

4142
It is possible to nest array fields - you can specify an instance of
4243
``ArrayField`` as the ``base_field``. For example::
@@ -178,7 +179,7 @@ Index transforms
178179
Index transforms index into the array. Any non-negative integer can be used.
179180
There are no errors if it exceeds the :attr:`max_size <ArrayField.max_size>` of
180181
the array. The lookups available after the transform are those from the
181-
:attr:`base_field <ArrayField.base_field>`. For example:
182+
:attr:`~ArrayField.base_field`. For example:
182183

183184
.. code-block:: pycon
184185
@@ -268,6 +269,20 @@ See :doc:`/topics/embedded-models` for more details and examples.
268269
created these models and then added an indexed field to ``Address``,
269270
the index created in the nested ``Book`` embed is not created.
270271

272+
``EmbeddedModelArrayField``
273+
---------------------------
274+
275+
.. class:: EmbeddedModelArrayField(embedded_model, **kwargs)
276+
277+
.. versionadded:: 5.2.0b1
278+
279+
Stores a list of models of type ``embedded_model``.
280+
281+
.. attribute:: embedded_model
282+
283+
This is a required argument, similar to
284+
:attr:`EmbeddedModelField.embedded_model`.
285+
271286
``ObjectIdAutoField``
272287
---------------------
273288

tests/model_fields_/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def __str__(self):
153153
# ArrayField + EmbeddedModelField
154154
class Review(EmbeddedModel):
155155
title = models.CharField(max_length=255)
156-
rating = models.IntegerField()
156+
rating = models.DecimalField(max_digits=6, decimal_places=1)
157157

158158
def __str__(self):
159159
return self.title

0 commit comments

Comments
 (0)