Setting a default on a select removes the settings passed in to populate the form

让人想犯罪 __ 提交于 2019-12-06 08:51:09
pswaminathan

From the WTForms Documentation:

Since BaseForm does not take its data at instantiation, you must call this to provide form data to the enclosed fields. Accessing the field’s data before calling process is not recommended.

But the Form subclass allows you to pass in objects as kwargs, which you are doing here. However, looking at the source, it looks like what is happening here is that __init__ is calling process to process the fields, so I think there is some overriding going on.

In any case, I think what is missing here is that the default value should be defined upon definition, not after instantiation. Look at the construction as well as this answer, and I think that will clear things up.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!