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
+27-5Lines changed: 27 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -4,17 +4,39 @@ This is an implementation of django's model forms for mongoengine documents.
4
4
5
5
## Requirements
6
6
7
-
* mongoengine
7
+
*[mongoengine](http://mongoengine.org/)
8
8
9
9
## Usage
10
10
11
+
mongodbforms supports forms for normal documents and embedded documents.
11
12
13
+
### Normal documents
12
14
13
-
## What works and doesn't work
15
+
To use mongodbforms with normal documents replace djangos forms with mongodbform forms.
14
16
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.
16
25
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',]
18
35
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.
0 commit comments