django Wizard——如何在向导中实现动态表单(或表单集)
我昨天问过类似的问题,但也许太具体了。
我在网上阅读了很多有关此问题的信息,但没有找到任何解决方案。
这是我想要实现的:
- 我想实现一个有两个步骤的向导。
第一步---ProductForm
一些固定字段,如名称,描述等
然后是一个动态字段图片,可以通过按钮添加,也就是说如果用户点击添加另一张图片,他应该看到一个新的 Image 字段出现
第二步---MoreInfoForm
用户完成 MoreInforForm,然后我们保存数据。
有人有想法吗?提前致谢!
I have asked a similar question yesterday but perhaps it was too concret.
I have read a lot about this on net, but I didn't find any solution.
Here is what I want to realize:
- I want to implement a wizard which has 2 steps.
first step---ProductForm
Some fixed fields like Name, Description, etc
Then a dynamic field Picture which can be added by a button, that is to say if the user clicks add another picture, he should see a new Image field shown up
second step---MoreInfoForm
The user finishes the MoreInforForm, then we save the data.
Does anyone have an idea? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚在这里回答了类似的问题:
django 1.3向导更改 form_list 以更改后续步骤
您需要创建两个单独的表单 - ProductForm 和 MoreInfoForm - 然后创建一个视图来处理这些表单。
该视图将检查是否已发布任何内容(即已提交表单),如果是,则决定是否需要提供新表单(在提交 ProductForm 的情况下 - 即步骤 1)或执行保存(在 MoreInfoForm 已提交的情况下 - 即步骤 2)
如果您需要保留第一个表单中的数据,直到填写第二个表单为止,您可以将此数据保存在会话变量中。
I just answered a similar question here:
django 1.3 wizard alter form_list to change next steps
You need to make two separate forms - a ProductForm and a MoreInfoForm - then you create a view to process these forms.
The view will check whether anything has been POSTed to it (i.e. a form has been submitted) and if so, decide if it needs to provide a new form (in the case of the ProductForm being submitted - i.e. step 1) or carry out a save (in the case that the MoreInfoForm has been submitted - i.e. step 2)
If there is data in the first form that you need to hold onto until the second form has been filled out, you can save this data in a session variable.