在Django表单中存储动态字段 [英] Storing dynamic fields in Django forms
问题描述
Django的表单库具有表单集的功能,可以让您处理动态添加的表单。例如,如果您的应用程序具有书签列表,您可以使用表单集,您可以使用表单集来处理各自表示书签的多个表单。
Django's form library has a feature of form sets that allow you to process dynamically added forms. For example you would use form sets if your application has a list of bookmarks you could use form sets to process multiple forms that each represent a bookmark.
如果您想要动态添加一个字段到窗体?一个例子是一个调查创建页面,您可以在其中动态添加无限数量的问题。在Django中如何处理这个问题?
What about if you want to dynamically add a field to a form? An example would be a survey creation page where you can dynamically add an unlimited number of questions. How do you handle this in Django?
推荐答案
看看最近由Jacob Kaplan-Moss发表的一篇文章, Django:动态表单生成。它使用一个例子来逐步显示过程。很棒的阅读。
Look at this recent post by Jacob Kaplan-Moss, one of the original founders of Django: "Dynamic form generation". It uses an example to show you the process step by step. Great read.
还有 James Bennett的2008年文章,Django的发行经理。
There is also a 2008 article by James Bennett, Django's release manager.
这篇关于在Django表单中存储动态字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!