问题描述
我正在制作一个Web应用程序,该Web应用程序需要一个表单向导.该向导由3个ModelForms组成,可以完美地工作.但是我需要第二种形式是编辑形式".也就是说,我需要将其作为传递实例的形式.
I am in the process of making a webapp, and this webapp needs to have a form wizard. The wizard consists of 3 ModelForms, and it works flawlessly. But I need the second form to be a "edit form". That is, i need it to be a form that is passed an instance.
如何使用表单向导执行此操作?如何传递模型实例?我看到FormWizard类具有get_form方法,但是是否存在使用Formwizard编辑/查看数据的文档化方法呢?
How can you do this with a form wizard? How do you pass in an instance of a model? I see that the FormWizard class has a get_form method, but isnt there a documented way to use the formwizard for editing/reviewing of data?
推荐答案
在Django 1.4中,您可以执行以下操作:
In Django 1.4 you can do something like:
def edit(request):
initial = {
0: {'subject': 'Hello', 'sender': '[email protected]'},
1: {'message': 'Hi there!'}
}
wiz = FormWizard([form1,form2,form3],initial_dict = initial)
return wiz(request)
这篇关于在Django中进行编辑的Formwizards的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!