@@ -210,6 +210,51 @@ transform do not change. For example:
210
210
211
211
These indexes use 0-based indexing.
212
212
213
+ ``EmbeddedModelField ``
214
+ ----------------------
215
+
216
+ .. class :: EmbeddedModelField(embedded_model, **kwargs)
217
+
218
+ Stores a model of type ``embedded_model ``.
219
+
220
+ .. attribute :: embedded_model
221
+
222
+ This is a required argument.
223
+
224
+ Specifies the model class to embed. It can be either a concrete model
225
+ class or a :ref: `lazy reference <lazy-relationships >` to a model class.
226
+
227
+ The embedded model cannot have relational fields
228
+ (:class: `~django.db.models.ForeignKey `,
229
+ :class: `~django.db.models.OneToOneField ` and
230
+ :class: `~django.db.models.ManyToManyField `).
231
+
232
+ It is possible to nest embedded models. For example::
233
+
234
+ from django.db import models
235
+ from django_mongodb_backend.fields import EmbeddedModelField
236
+
237
+ class Address(models.Model):
238
+ ...
239
+
240
+ class Author(models.Model):
241
+ address = EmbeddedModelField(Address)
242
+
243
+ class Book(models.Model):
244
+ author = EmbeddedModelField(Author)
245
+
246
+ See :doc: `embedded-models ` for more details and examples.
247
+
248
+ .. admonition :: Migrations support is limited
249
+
250
+ :djadmin: `makemigrations ` does not yet detect changes to embedded models.
251
+
252
+ After you create a model with an ``EmbeddedModelField `` or add an
253
+ ``EmbeddedModelField `` to an existing model, no further updates to the
254
+ embedded model will be made. Using the models above as an example, if you
255
+ created these models and then added an indexed field to ``Address ``,
256
+ the index created in the nested ``Book `` embed is not created.
257
+
213
258
``ObjectIdField ``
214
259
-----------------
215
260
0 commit comments