File tree Expand file tree Collapse file tree 1 file changed +23
-4
lines changed Expand file tree Collapse file tree 1 file changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ In the template::
127
127
MongoEngine and WTForms
128
128
=======================
129
129
130
- You can use MongoEngine and WTForms like so ::
130
+ flask-mongoengine automatically generates WTForms from MongoEngine models ::
131
131
132
132
from flask_mongoengine.wtf import model_form
133
133
@@ -155,9 +155,28 @@ You can use MongoEngine and WTForms like so::
155
155
redirect('done')
156
156
return render_template('add_post.html', form=form)
157
157
158
+ For each MongoEngine field, the most appropriate WTForm field is used.
159
+ Parameters allow the user to provide hints if the conversion is not implicit::
160
+
161
+ PostForm = model_form(Post, field_args={'title': {'textarea': True}})
162
+
163
+ Supported parameters:
164
+
165
+ For fields with `choices `:
166
+
167
+ - `multiple ` to use a SelectMultipleField
168
+ - `radio ` to use a RadioField
169
+
170
+ For `StringField `:
171
+
172
+ - `password ` to use a PasswordField
173
+ - `textarea ` to use a TextAreaField
174
+
175
+ (By default, a StringField is converted into a TextAreaField if and only if it has no max_length.)
176
+
158
177
159
178
Supported fields
160
- ================
179
+ ----------------
161
180
162
181
* StringField
163
182
* BinaryField
@@ -175,7 +194,7 @@ Supported fields
175
194
* DictField
176
195
177
196
Not currently supported field types:
178
- ====================================
197
+ ------------------------------------
179
198
180
199
* ObjectIdField
181
200
* GeoLocationField
@@ -229,7 +248,7 @@ Upgrading
229
248
230
249
231
250
Credits
232
- ========
251
+ =======
233
252
234
253
Inspired by two repos:
235
254
You can’t perform that action at this time.
0 commit comments