Skip to content

Commit e6b09ed

Browse files
author
Jan Schrewe
committed
Small read me update. Added .gitignore.
1 parent a3cd5b2 commit e6b09ed

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.pyc
2+
.pydevproject
3+
.project

readme.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,54 @@ For embedded documents use `EmbeddedDocumentForm`. The Meta-object of the form h
4040

4141
django-mongodbforms currently only supports the most basic things and even they are not really tested.
4242

43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
An implementation of django's model forms for mongoengine documents. I am aware that there is already a [similar project](https://github.com/stephrdev/django-mongoforms), but I needed support for django's `modelform_factory` and `formset_factory`. The code used in this project is mostly taken from django's modelform code.
54+
55+
## Note
56+
57+
**This is pre-alpha software.** Most things are not really tested and although we try to use it wherever posible, you may stumble over weird bugs or your server might explode.
58+
59+
## What works
60+
61+
You should be able to use *mongodbforms* just like django's standard forms. If you can't you have most likely found a bug. [Report it, please.](https://github.com/jschrewe/django-mongodbforms/issues) Thank you.
62+
63+
## Usage
64+
65+
mongodbforms supports forms for normal documents and embedded documents.
66+
67+
### Normal documents
68+
69+
To use mongodbforms with normal documents replace djangos forms with mongodbform forms.
70+
71+
from mongodbforms import DocumentForm
72+
73+
class BlogForm(DocumentForm)
74+
...
75+
76+
### Embedded documents
77+
78+
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.
79+
80+
# forms.py
81+
from mongodbforms import EmbeddedDocumentForm
82+
83+
class MessageForm(EmbeddedDocumentForm):
84+
class Meta:
85+
document = Message
86+
embedded_field_name = 'messages'
87+
88+
fields = ['subject', 'sender', 'message',]
89+
90+
# views.py
91+
form = MessageForm(parent_document=some_document, ...)
92+
93+

0 commit comments

Comments
 (0)