Form wizard get_template_names()

366 views
Skip to first unread message

Dario Vergara

unread,
Jul 10, 2011, 10:15:42 AM7/10/11
to Django users
Hi,

I am using the development version of FormWizard. The documentation
says that you can change the default template name by overriding
get_template_names(). My implementation seems to always return the
same template:

class MyWizard(SessionWizardView):

def done(self, form_list, **kwargs):
return render_to_response('done.html', {
'form_data': [form.cleaned_data for form in form_list],
})

def get_template_names(self):
return ['./mysite/step_1.html','./mysite/step_2.html']


Any idea on how to make the template change to step_2 after the user
clicks next on step 1?

The documentation on how to implement this method is missing from
https://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-wizard/.

Dario Vergara

unread,
Jul 12, 2011, 10:31:58 PM7/12/11
to Django users
Here is the solution:

def get_template_names(self):
next_step = int(self.steps.current)
return 'step_%s.html' % next_step


Simple solution. What is confusing is that the documentation says that
get_template_names() should return a list.

Juan Miguel Taboada

unread,
Apr 23, 2014, 1:20:23 AM4/23/14
to django...@googlegroups.com

I would like to point that your example doesn't return a list.
Reply all
Reply to author
Forward
0 new messages