@@ -5,6 +5,49 @@ Model field reference
55
66Some MongoDB-specific fields are available in ``django_mongodb_backend.fields ``.
77
8+ ``EmbeddedModelField ``
9+ ----------------------
10+
11+ .. class :: EmbeddedModelField(embedded_model, **kwargs)
12+
13+ Stores a model of type ``embedded_model ``.
14+
15+ .. attribute :: embedded_model
16+
17+ This is a required argument.
18+
19+ Specifies the model class to embed. It can be either a concrete model
20+ class or a :ref: `lazy reference <lazy-relationships >` to a model class.
21+
22+ The embedded model cannot have relational fields
23+ (:class: `~django.db.models.ForeignKey `,
24+ :class: `~django.db.models.OneToOneField ` and
25+ :class: `~django.db.models.ManyToManyField `).
26+
27+ It is possible to nest embedded models. For example::
28+
29+ from django.db import models
30+ from django_mongodb.fields import EmbeddedModelField
31+
32+ class Address(models.Model):
33+ ...
34+
35+ class Author(models.Model):
36+ address = EmbeddedModelField(Address)
37+
38+ class Book(models.Model):
39+ author = EmbeddedModelField(Author)
40+
41+ .. admonition :: Migrations support is limited
42+
43+ :djadmin: `makemigrations ` does not yet detect changes to embedded models.
44+
45+ After you create a model with an ``EmbeddedModelField `` or add an
46+ ``EmbeddedModelField `` to an existing model, no further updates to the
47+ embedded model will be made. Using the models above as an example, if you
48+ created these models and then added an indexed field to ``Address ``,
49+ the index created in the nested ``Book `` embed is not created.
50+
851``ObjectIdField ``
952-----------------
1053
0 commit comments