I was looking at the documentation and I am not quite sure how to use different templates for each step…
I looked into the source code and it seems that the template name is hardcoded:
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'
...........
The docs say something about mixins, but I am not sure how to use them since I just started with django…
Thanks
UPDATE:
I looked further into the source code and realized that there is a method get_template_names.
I tried:
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],
})
But got an error:
get_template_names() takes exactly 2 arguments (1 given)
get_template_namesdoesn’t accept arguments. You can’t just define a new argument for a function to accept and hope the framework will pass it in! (for your future troubleshooting)Judging by the
WizardViewsource, it looks like you can access the currently active step viaself.steps.currentwhich you could use in yourget_template_namesview to return a path containing the step.I’m not sure if
currentis a string or integer or what – but one look at the view and you should find a useful “can’t find template named X” error.