Opened 8 years ago

Closed 8 years ago

#19285 closed New feature (duplicate)

Allow to redirect user back in Form wizard

Reported by: azurit Owned by: nobody
Component: contrib.formtools Version: 1.4
Severity: Normal Keywords: form wizard formwizard
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


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/ in method:

        # 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():
   = wizard_goto_step
            form = self.get_form(
            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:

        done_response = self.done(final_form_list, * *kwargs)
        return done_response

I altered this method to make it work also in final step like this:

        done_response = self.done(final_form_list, **kwargs)
        if self.steps.current == self.steps.last:
        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?

Change History (2)

comment:1 Changed 8 years ago by Russell Keith-Magee

Needs documentation: set
Triage Stage: UnreviewedAccepted

I think this may just be a documentation issue. For my money, part of the design contract for the Form Wizard is that once validated, the form will be able to reliably save without error.

In your case, I think this means that you need to 'reserve' the username as part of the validation process -- i.e., when the form validates for user1, it stores a value in temporary storage that would prevent user2 from validating with the same value. You could use something as simple as a cache key, or even a whole temporary table to handle this.

I'm accepting this ticket on the basis that the design contract needs to be better documented, and possibly use cases like yours need to be highlighted as part of that documentation.

comment:2 Changed 8 years ago by Russell Keith-Magee

Resolution: duplicate
Status: newclosed

Actually, marking this as a duplicate of #19189.

Note: See TracTickets for help on using tickets.
Back to Top