wtforms ReferencePropertyField 设置已选择

发布于 2024-11-25 06:39:47 字数 246 浏览 4 评论 0原文

使用 GAE-helper ReferencePropertyField 显示用户可能所在的组。

编辑用户时如何使其显示用户当前所在的组?

选择字段工作正常,我可以更改用户组并将更改写入数据存储区,但我不知道如何在重新渲染表单时设置当前值。

我尝试过使用

form.field.data = current_data

但没有运气。

有人有主意吗?

Using the GAE-helper ReferencePropertyField to show possible groups that a user can be in.

How do I make it show the what group the user currently is in when editing the user?

The selectfield works fine, I can change the group of the user and the changes are written to the datastore, but I can't figure out how to set the current value when redering the form.

I have tried using

form.field.data = current_data

but with no luck.

Anyone have an idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痴情换悲伤 2024-12-02 06:39:47

current_data 是字符串吗?如果不尝试使用 str(current_data) 进行转换,我在使用实体键或 id 作为 SelectField 上的值时遇到了类似的问题。

Is current_data a string? If not try using str(current_data) to convert, I had a similar issue using either entity keys or ids as values on a SelectField.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文