This question is a bit old, but I had this issue and wanted to provide a solution in case someone else is googling this question.
I liked Brian H's solution, but if you are on the final step and you want to go to the previous step, it's actually going to submit the form and run the done function. I could not find a solution to fix this, so I will propose a different solution. All you need to do is overwrite the render_goto_step
on the WizardView
.
def render_goto_step(self, *args, **kwargs):
form = self.get_form(data=self.request.POST, files=self.request.FILES)
if form.is_valid():
self.storage.set_step_data(self.steps.current, self.process_step(form))
self.storage.set_step_files(self.steps.current, self.process_step_files(form))
return super().render_goto_step(*args, **kwargs)
Essentially, it saves the data of the current form before it renders the given step, but only if the form is valid. I suppose you could save the data regardless if it's valid or not, but I haven't tested it this way.