在 Django 中,如何在模板中手动构建表单集?
我正在模板中手动构建表单集的各个部分。 如何获取隐藏字段 TOTAL_FORMS 和 INITIAL_FORMS。 是否有一个隐藏的显示小部件,其中已经存在我可以调用的?
<label>formset title</label>
#formset.TOTAL_FORMS
#formset.INITIAL_FORMS
{% for form in formset.forms %}
{{form.field}}
{{form.id}}
{% endfor %}
I am constructing the pieces of a formset manually in a template. How do I get the hidden fields TOTAL_FORMS and INITIAL_FORMS. Is there a hidden display widget with them in it already there that I can call?
<label>formset title</label>
#formset.TOTAL_FORMS
#formset.INITIAL_FORMS
{% for form in formset.forms %}
{{form.field}}
{{form.id}}
{% endfor %}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还可以通过仅输出管理表单来快捷方式,该表单由这两个隐藏字段组成:
我没有正确引用此信息,可以在以下位置找到该信息: http://docs.djangoproject.com/en/dev/topics/forms/formsets/
You can also shortcut that by just outputting the management form, which consists of those two hidden fields:
I didn't properly cite this info, which can be found at: http://docs.djangoproject.com/en/dev/topics/forms/formsets/
在探索内部结构时,我找到了我自己问题的答案:
In poking around in the internals I found the answer to my own question: