我正在查看文档,但我不太确定如何为每个步骤使用不同的模板......
我查看了源代码,似乎模板名称是硬编码的:
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'
...........
文档说了一些关于 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': [form.cleaned_data for form in form_list],
})
但出现错误:
get_template_names() takes exactly 2 arguments (1 given)