如何在视图中包装Django 表单向导?我需要这样做才能访问request.
有没有人有一些示例代码?
我正在查看文档,我不太确定如何为每个步骤使用不同的模板...
我查看了源代码,似乎模板名称是硬编码的:
class WizardView(TemplateView):
"""
The WizardView is used to create multi-page forms and handles all the
storage and validation stuff. The wizard is based on Django's generic
class based views.
"""
storage_name = None
form_list = None
initial_dict = None
instance_dict = None
condition_dict = None
template_name = 'formtools/wizard/wizard_form.html'
...........
Run Code Online (Sandbox Code Playgroud)
文档说了一些关于mixins的内容,但我不知道如何使用它们,因为我刚开始使用django ...
谢谢
更新:
我进一步研究了源代码并意识到有一种方法get_template_names.
我试过了:
class AddWizard(SessionWizardView):
def get_template_names(self, step):
if step == 0:
return 'business/add1.html'
return 'business/add2.html'
def done(self, form_list, **kwargs):
return render_to_response('business/done.html', {
'form_data': …Run Code Online (Sandbox Code Playgroud)