You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+15-10Lines changed: 15 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -26,18 +26,23 @@ For embedded documents use `EmbeddedDocumentForm`. The Meta-object of the form h
26
26
27
27
If no position is provided the form adds a new embedded document to the list if the form is saved. To edit an embedded document stored in a list field the position argument is required. If you provide a position and no instance to the form the instance is automatically loaded using the position argument. If the embedded field is a plain embedded field the current object is overwritten.
28
28
29
-
# forms.py
30
-
from mongodbforms import EmbeddedDocumentForm
29
+
````python
30
+
# forms.py
31
+
from mongodbforms import EmbeddedDocumentForm
31
32
32
-
class MessageForm(EmbeddedDocumentForm):
33
-
class Meta:
34
-
document = Message
35
-
embedded_field_name = 'messages'
33
+
classMessageForm(EmbeddedDocumentForm):
34
+
classMeta:
35
+
document = Message
36
+
embedded_field_name ='messages'
36
37
37
-
fields = ['subject', 'sender', 'message',]
38
-
39
-
# views.py
40
-
form = MessageForm(parent_document=some_document, ...)
38
+
fields = ['subject', 'sender', 'message',]
39
+
40
+
# views.py
41
+
# create a new embedded object
42
+
form = MessageForm(parent_document=some_document, ...)
43
+
# edit the 4th embedded object
44
+
form = MessageForm(parent_document=some_document, position=3, ...)
0 commit comments