Skip to content

Commit 6ad8c05

Browse files
author
Jan Schrewe
committed
More docs
1 parent d020626 commit 6ad8c05

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

readme.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,23 @@ For embedded documents use `EmbeddedDocumentForm`. The Meta-object of the form h
2626

2727
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.
2828

29-
# forms.py
30-
from mongodbforms import EmbeddedDocumentForm
29+
````python
30+
# forms.py
31+
from mongodbforms import EmbeddedDocumentForm
3132

32-
class MessageForm(EmbeddedDocumentForm):
33-
class Meta:
34-
document = Message
35-
embedded_field_name = 'messages'
33+
class MessageForm(EmbeddedDocumentForm):
34+
class Meta:
35+
document = Message
36+
embedded_field_name = 'messages'
3637

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, ...)
45+
```
4146

4247
## Documentation
4348

0 commit comments

Comments
 (0)