stephrdev / django-mongoforms Goto Github PK
View Code? Open in Web Editor NEWA Django-ModelForm clone for mongoengine
License: BSD 3-Clause "New" or "Revised" License
A Django-ModelForm clone for mongoengine
License: BSD 3-Clause "New" or "Revised" License
When I installed this on my machine, the package didn't seem to set itself up correctly.
I ran:
python setup.py install
to install my application. But it looks like my /usr/lib/python2.6/dist-packages
directory only contains a django_mongoforms-0.2-py2.7.egg
folder. I expect it to contain a mongoforms/
folder as well. The mongoforms folder is hidden in the django_mongoforms-0.2-py2.7.egg
folder.
Is this an issue with my installation or an issue with the packaging?
Thanks.
django version 1.8.1
mongoforms/forms.py in MongoForm, line 57
def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
initial=None, error_class=forms.util.ErrorList, label_suffix=':',
empty_permitted=False, instance=None):
forms.utils.ErrorList
forms.BaseForm's init method has a third attribute "files", MongoForm does not have such method, so uploading multipart forms with forms.ImageField and so on is impossible right now, the form just does not validate.
utils.py is should have the import:
from django import forms
I have a field with unique=True, but mongoforms does not seems to ignore that.
5 class SignupForm(MongoForm):
6 class Meta:
7 document = User
8 fields = ('username', 'email', 'password')
9 password = forms.CharField(widget=forms.PasswordInput, label="Your password")
10 repeat_password = forms.CharField(widget=forms.PasswordInput, label="Repeat password")
But the order of the form is
username
password
email
repeat_password
Any chance you could get this to PyPI? That would be very useful. Until then I need to use this command to install:
pip install https://github.com/stephrdev/django-mongoforms/tarball/master
There are a number of forms that looks half way there to add FileField support. Are you planning in adding it yourself or you are waiting for a pull request to come up?
I made a ModelForm by metaclass a document, but in which the stringField seems not to support regex in model.
with error such as:
Error when calling the metaclass bases
init() got an unexpected keyword argument 'regex'
Hi,
Here is a simple scenario: I have a blog post with comments attach to it. Now I want to use mongoforms to let user submit their comments. Therefore I have this models.py:
class Post(Document):
title = StringField(max_length=60)
body = StringField()
created = DateTimeField(default=datetime.datetime.now)
comments = ListField(EmbeddedDocumentField('Comment'))
class Comment(EmbeddedDocument):
author = StringField(max_length=60)
body = StringField()
created = DateTimeField(default=datetime.datetime.now)
And the forms.py:
class CommentForm(MongoForm):
class Meta:
document = Comment
fields = ('author', 'body')
In the views.py, I just want to save what user has entered, more specifically Author and Body of the comments:
post = Post.objects.with_id(id)
if request.method == 'POST':
form = CommentForm(request.POST, instance=post.comments)
if form.is_valid():
form.save()
return HttpResponseRedirect(post.get_absolute_url())
But apparently the post.comments is a BaseList not directly inherit from Document, so I got this error:
instance must be a mongoengine document, not BaseList
The question is what's the best practice in this case, say update the EmbeddedDocument?
Thank you!
I found that inside the StringField generator function, it is zipping the choice data and makeing it a copy. This results in to a dictionary with non string key. This will throw an error if we convert a dictionary of non string key to json format.
It's worked form if I'm removing the zip statement from the Field generation function of StringField.
Thank you,
haridas N.
Is there a way to create hidden input fields?
Is there any build-in forms, such as for registering and login forms?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.