user1911075 February 2016

What is the correct way to use flask-mongoengine field kwargs?

I want to set an additional parameter ("order") when defining a MongoEngine field in my Python Model which I can then access in my View.

Note: "order" is a custom parameter; MongoEngine documentation states that kwargs can added.

I've tried:

class Tasks(Document):
    complete = BooleanField(default=False, **{'order':0})
    task = StringField(max_length=128)

The error encountered is:

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

I've searched the MongoEngine documentation for examples, to no avail. I've also been reading on how to use **kwargs in Python, but am not understanding how to apply.

Can you provide an example of how to include additional parameters to those already in the BaseField?

Answers


Tony February 2016

According to field description of mongoengine doc, it does't offer order argument.

Post Status

Asked in February 2016
Viewed 2,361 times
Voted 9
Answered 1 times

Search




Leave an answer