MongoDB Forms
Get the source: https://github.com/jschrewe/django-mongodbforms
An implementation of django's model forms for mongoengine documents. I am aware that there is already a similar project, 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.
What works
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. Thank you.
Usage
mongodbforms supports forms for normal documents and embedded documents.
Normal documents
To use mongodbforms with normal documents replace djangos forms with mongodbform forms.
from mongodbforms import DocumentForm
class BlogForm(DocumentForm)
...
Embedded documents
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.
# forms.py
from mongodbforms import EmbeddedDocumentForm
class MessageForm(EmbeddedDocumentForm):
class Meta:
document = Message
embedded_field_name = 'messages'
fields = ['subject', 'sender', 'message',]
# views.py
form = MessageForm(parent_document=some_document, ...)
Latest commits
-
Jan Schrewe | about vor etwa 3 Tagen
-
Yin Jifeng | about vor etwa 15 Tagen
-
Yin Jifeng | about vor etwa 16 Tagen
-
Yin Jifeng | about vor etwa 16 Tagen
-
Jan Schrewe | about vor etwa 51 Tagen
