Skip to content

Commit 747215c

Browse files
committed
Use help_text for field description (MongoEngine#43)
1 parent 3285829 commit 747215c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

flask_mongoengine/wtf/orm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, converters=None):
3838
def convert(self, model, field, field_args):
3939
kwargs = {
4040
'label': getattr(field, 'verbose_name', field.name),
41-
'description': '',
41+
'description': field.help_text or '',
4242
'validators': [],
4343
'filters': [],
4444
'default': field.default,

tests/test_forms.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,5 +247,20 @@ class DogOwner(db.Document):
247247
self.assertIsNotNone(m, "Should have one selected option")
248248
self.assertEqual("fido", m.group(1))
249249

250+
def test_model_form_help_text(self):
251+
with self.app.test_request_context('/'):
252+
db = self.db
253+
254+
class BlogPost(db.Document):
255+
title = db.StringField(required=True, help_text="Some imaginative title to set the world on fire")
256+
257+
post = BlogPost(title="hello world").save()
258+
259+
BlogPostForm = model_form(BlogPost)
260+
form = BlogPostForm(instance=post)
261+
262+
self.assertEqual(form.title.description, "Some imaginative title to set the world on fire")
263+
264+
250265
if __name__ == '__main__':
251266
unittest.main()

0 commit comments

Comments
 (0)