[Flask] flask-mongoengine custom field parameters

Jerry Mccreary jerry.mccreary at mac.com
Wed Feb 10 17:04:17 EST 2016


Is it possible to add custom field parameters when defining a model
when using flask-mongoengine? (which in turn uses WTForms)

Example:

class Tasks(Document):
    task = StringField(max_length=128, my_custom_param="hello")
    completed = BooleanField(default=False)

The above will generate an error:

     flask_mongoengine/wtf/base.py", line 23, in __init__
        BaseField.__init__(self, **kwargs)
    TypeError: __init__() got an unexpected keyword argument 'my_custom_param'

Would it be a matter of defining or extending in the model __init__ method?

If it's possible, could anyone provide an example?


Thanks.

Jerry McCreary

––––––––––––––––––



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160210/b3c4c88f/attachment.html>


More information about the Flask mailing list