【发布时间】:2011-05-30 01:32:21
【问题描述】:
我想自定义表单集中表单的布局(即我不想使用 .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 %}
有没有“为表单集字段创建 ID”之类的方法?
【问题讨论】:
标签: django django-forms