在 Django 中,如何在模板中手动构建表单集?

发布于 2024-07-29 00:57:03 字数 285 浏览 3 评论 0原文

我正在模板中手动构建表单集的各个部分。 如何获取隐藏字段 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

三岁铭 2024-08-05 00:57:03

您还可以通过仅输出管理表单来快捷方式,该表单由这两个隐藏字段组成:

{{ formset.management_form }}

我没有正确引用此信息,可以在以下位置找到该信息: 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:

{{ formset.management_form }}

I didn't properly cite this info, which can be found at: http://docs.djangoproject.com/en/dev/topics/forms/formsets/

自控 2024-08-05 00:57:03

在探索内部结构时,我找到了我自己问题的答案:

{{formset.management_form.TOTAL_FORMS}}
{{formset.management_form.INITIAL_FORMS}}

In poking around in the internals I found the answer to my own question:

{{formset.management_form.TOTAL_FORMS}}
{{formset.management_form.INITIAL_FORMS}}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文