在Django窗体中构建的as_html,as_ul,as_p方法不适用于我,也不在{{field}}
中进行渲染,因此我正在尝试编写自定义窗体渲染。如何获取django模板中的BoundField的值?
这是我到目前为止有:
<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
支持value
或data
属性。我正在使用ModelForms,如果它很重要