Tur*_*yes 1 django django-forms
我想在formset中自定义表单的布局(也就是说,我不想使用.as_table()或.as_p()等).我正在尝试获取表单字段的名称以用于其标签的for属性,但我不确定如何去做.我希望我不需要从头开始为该字段构建新的名称/ ID.这是我现在正在使用的一个例子:
{% for form in formset.forms %}
<!-- The field for the "path" form field -->
<label for="{{what do I put here?}}">{{form.fields.path.label}}:</label><input type="text" id="{{django creates this one; do I have to do my own with the for loop counter or something?}}" name="{{probably the same as id}}" />
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
是否有任何类型的"为formset字段创建ID"的方法?
| 归档时间: |
|
| 查看次数: |
4155 次 |
| 最近记录: |