gpt4 book ai didi

django - 如何在 django 模板中获取 BoundField 的值?

转载 作者:行者123 更新时间:2023-12-04 15:53:50 25 4
gpt4 key购买 nike

Django 表单上的内置 as_html、as_ul、as_p 方法对我不起作用,内置的 {{field}} 也不起作用。渲染,所以我正在尝试编写自定义表单渲染。

这是我到目前为止所拥有的:

    <input id="id_{{field.html_name}}" 
type="text"
name="{{field.html_name}}"
placeholder="{{field.label}}" <!-- "placeholder" is really the only reason I need to do a custom implementation -->
value="{{ XXX }}" <!-- what goes here? -->
maxlength="30" />

问题是, value 属性中应该包含什么(上面标记为 XXX)?

我环顾四周,似乎没有 BoundField支持 valuedata属性。如果重要的话,我正在使用 ModelForms

最佳答案

value属性登陆后备箱in 2010 .该补丁显示了如何使用表单/数据检索值(不幸的是,在模板中并不简单)。工单注释中有一些模板标记代码片段,您可能会觉得有用。

关于django - 如何在 django 模板中获取 BoundField 的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4310214/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com