Internally, what are the differences between these two fields? What kind of schema do these fields map to in mongo? Also, how should documents with relations be added to the
EmbeddedDocumentField
is just path of parent document like DictField
and stored in one record with parent document in mongo.
To save EmbeddedDocument
just save parent document.
>>> some_author = User.objects.get(name="ExampleUserName")
>>> post = Post.objects.get(author=some_author)
>>> post.comments
[]
>>> comment = Comment(text="cool post", tag="django")
>>> post.comment.append(comment)
>>> post.save()
>>> post.comment
[]
>>> Post.objects.get(author=some_author).comment
[]
See documentation: http://docs.mongoengine.org/guide/defining-documents.html#embedded-documents.