﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
19285	Allow to redirect user back in Form wizard	azurit	nobody	"I was fighting with problem in allowing to redirect user back when using Form wizard. Here is the use case:

 - user1 will choose a login and password in first step, login availability is checked
 - user1 is redirected to second step where he needs to fill up other important data for creating his account
 - meanwhile, user2 registers and takes login of user1
 - finally, we got an error when creating the account for user1. here we need to redirect him to first step and ask him for another login

I wasn't able to find any way how to do this. Finally i was trying to simulate usage of 'Go back' button, which is defined in contrib/formtools/wizard/views.py in WizardView.post() method:
{{{#!python
        # Look for a wizard_goto_step element in the posted data which
        # contains a valid step name. If one was found, render the requested
        # form. (This makes stepping back a lot easier).
        wizard_goto_step = self.request.POST.get('wizard_goto_step', None)
        if wizard_goto_step and wizard_goto_step in self.get_form_list():
            self.storage.current_step = wizard_goto_step
            form = self.get_form(
                data=self.storage.get_step_data(self.steps.current),
                files=self.storage.get_step_files(self.steps.current))
            return self.render(form)
}}}
Unfortunately this won't work in final step, becase of resetting the form wizard in the same file at the end of WizardView.render_done() method:
{{{#!python
        done_response = self.done(final_form_list, * *kwargs)
        self.storage.reset()
        return done_response
}}}
I altered this method to make it work also in final step like this:
{{{#!python
        done_response = self.done(final_form_list, **kwargs)
        if self.steps.current == self.steps.last:
            self.storage.reset()
        return done_response
}}}
Do you consider this as a usefull patch which can be included in Django? Or can you suggest another correct way how to do this?"	New feature	closed	contrib.formtools	1.4	Normal	duplicate	form wizard formwizard		Accepted	0	1	0	0	0	0
