Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Form Wizard, how to reset/clear wizard when I'm not done yet?

Tags:

I have a working Form Wizard. To get to the wizard the user will click a button from the home page.

If I finish the wizard (three steps) and go back to the home page and click the button again, there's no problem. The wizard is good as new again and all the forms are empty which is what we want.

However if you didn't finish the wizard, like say I'm on the second step and I went back to the home page, click the button there, I'll be back to the second page. That's not what we want. We want a brand new wizard.

I want to implement a "cancel" or "reset" button that if clicked, the user will be redirected to the home page and when the user clicks the button they will be go to the first step of the wizard with all forms empty.

like image 584
johnjullies Avatar asked Jun 01 '16 10:06

johnjullies


1 Answers

I got it. Apparently I only have to add a reset query param to the url that points to the wizard.

So my <a href="{% url 'go_to_wizard' %}">

becomes <a href="{% url 'go_to_wizard' %}?reset">

and the session will reset and I will go to step 1 of the wizard. Found it after looking at the source code (Hint: line 647).

like image 181
johnjullies Avatar answered Sep 28 '22 04:09

johnjullies