Using different templates with django form wizard
django, django-forms, django-formwizard
Solution
`get_template_names` doesn'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 `WizardView` source, it looks like you can access the currently active step via `self.steps.current` which you could use in your `get_template_names` view to return a path containing the step.
class AddWizard(SessionWizardView):
def get_template_names(self):
return ['step_{0}_template.html'.format(self.steps.current)]
I'm not sure if `current` is 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.
Problem
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)`