Skip to content

Commit aa38c4e

Browse files
author
jschrewe
committed
Updated readme a bit.
1 parent 1d1ebc0 commit aa38c4e

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

readme.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,39 @@ This is an implementation of django's model forms for mongoengine documents.
44

55
## Requirements
66

7-
* mongoengine
7+
* [mongoengine](http://mongoengine.org/)
88

99
## Usage
1010

11+
mongodbforms supports forms for normal documents and embedded documents.
1112

13+
### Normal documents
1214

13-
## What works and doesn't work
15+
To use mongodbforms with normal documents replace djangos forms with mongodbform forms.
1416

15-
django-mongodbforms currently only supports the most basic things and even they are not really tested.
17+
from mongodbforms import DocumentForm
18+
19+
class BlogForm(DocumentForm)
20+
...
21+
22+
### Embedded documents
23+
24+
For embedded documents use `EmbeddedDocumentForm`. The Meta-object of the form has to be provided with an embedded field name. The embedded object is appended to this. The form constructor takes an additional argument: The document the embedded document gets added to.
1625

17-
Changelists only support basic listings you probably won't be able to use fieldlists and every other feature that django supports for changelists (search, etc.).
26+
# forms.py
27+
from mongodbforms import EmbeddedDocumentForm
28+
29+
class MessageForm(EmbeddedDocumentForm):
30+
class Meta:
31+
document = Message
32+
embedded_field_name = 'messages'
33+
34+
fields = ['subject', 'sender', 'message',]
1835

19-
Inline admin objects are created automatically for embedded objects, but can't be defined manually for referenced objects. Although I haven't tested it, field widget can't be overwritten.
36+
# views.py
37+
form = MessageForm(parent_document=some_document, ...)
38+
39+
## What works and doesn't work
40+
41+
django-mongodbforms currently only supports the most basic things and even they are not really tested.
2042

0 commit comments

Comments
 (0)