diff --git a/django/contrib/formtools/templates/formtools/wizard/wizard_form.html b/django/contrib/formtools/templates/formtools/wizard/wizard_form.html
index fe75522..95bc576 100644
a
|
b
|
|
12 | 12 | {% endif %} |
13 | 13 | |
14 | 14 | {% if wizard.steps.prev %} |
15 | | <button name="wizard_prev_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button> |
16 | | <button name="wizard_prev_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button> |
| 15 | <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button> |
| 16 | <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button> |
17 | 17 | {% endif %} |
18 | 18 | <input type="submit" name="submit" value="{% trans "submit" %}" /> |
diff --git a/django/contrib/formtools/tests/wizard/namedwizardtests/tests.py b/django/contrib/formtools/tests/wizard/namedwizardtests/tests.py
index 0f63882..e4ec80e 100644
a
|
b
|
class NamedWizardTests(object):
|
83 | 83 | response = self.client.post( |
84 | 84 | reverse(self.wizard_urlname, kwargs={ |
85 | 85 | 'step': response.context['wizard']['steps'].current |
86 | | }), {'wizard_prev_step': response.context['wizard']['steps'].prev}) |
| 86 | }), {'wizard_goto_step': response.context['wizard']['steps'].prev}) |
87 | 87 | response = self.client.get(response['Location']) |
88 | 88 | |
89 | 89 | self.assertEqual(response.status_code, 200) |
diff --git a/django/contrib/formtools/tests/wizard/wizardtests/tests.py b/django/contrib/formtools/tests/wizard/wizardtests/tests.py
index 9868721..1d325fd 100644
a
|
b
|
class WizardTests(object):
|
52 | 52 | self.assertEqual(response.context['wizard']['steps'].current, 'form2') |
53 | 53 | |
54 | 54 | response = self.client.post(self.wizard_url, { |
55 | | 'wizard_prev_step': response.context['wizard']['steps'].prev}) |
| 55 | 'wizard_goto_step': response.context['wizard']['steps'].prev}) |
56 | 56 | self.assertEqual(response.status_code, 200) |
57 | 57 | self.assertEqual(response.context['wizard']['steps'].current, 'form1') |
58 | 58 | |
diff --git a/django/contrib/formtools/wizard/views.py b/django/contrib/formtools/wizard/views.py
index 15ba146..940e95c 100644
a
|
b
|
class WizardView(TemplateView):
|
243 | 243 | wasn't successful), the next step (if the current step was stored |
244 | 244 | successful) or the done view (if no more steps are available) |
245 | 245 | """ |
246 | | # Look for a wizard_prev_step element in the posted data which |
| 246 | # Look for a wizard_goto_step element in the posted data which |
247 | 247 | # contains a valid step name. If one was found, render the requested |
248 | 248 | # form. (This makes stepping back a lot easier). |
249 | | wizard_prev_step = self.request.POST.get('wizard_prev_step', None) |
250 | | if wizard_prev_step and wizard_prev_step in self.get_form_list(): |
251 | | self.storage.current_step = wizard_prev_step |
| 249 | wizard_goto_step = self.request.POST.get('wizard_goto_step', None) |
| 250 | if wizard_goto_step and wizard_goto_step in self.get_form_list(): |
| 251 | self.storage.current_step = wizard_goto_step |
252 | 252 | form = self.get_form( |
253 | 253 | data=self.storage.get_step_data(self.steps.current), |
254 | 254 | files=self.storage.get_step_files(self.steps.current)) |
… |
… |
class NamedUrlWizardView(WizardView):
|
638 | 638 | Do a redirect if user presses the prev. step button. The rest of this |
639 | 639 | is super'd from FormWizard. |
640 | 640 | """ |
641 | | prev_step = self.request.POST.get('wizard_prev_step', None) |
642 | | if prev_step and prev_step in self.get_form_list(): |
643 | | self.storage.current_step = prev_step |
644 | | return redirect(self.url_name, step=prev_step) |
| 641 | wizard_goto_step = self.request.POST.get('wizard_goto_step', None) |
| 642 | if wizard_goto_step and wizard_goto_step in self.get_form_list(): |
| 643 | self.storage.current_step = wizard_goto_step |
| 644 | return redirect(self.url_name, step=wizard_goto_step) |
645 | 645 | return super(NamedUrlWizardView, self).post(*args, **kwargs) |
646 | 646 | |
647 | 647 | def render_next_step(self, form, **kwargs): |
diff --git a/docs/ref/contrib/formtools/form-wizard.txt b/docs/ref/contrib/formtools/form-wizard.txt
index aadd7d2..197d04b 100644
a
|
b
|
Here's a full example template:
|
206 | 206 | {% endif %} |
207 | 207 | </table> |
208 | 208 | {% if wizard.steps.prev %} |
209 | | <button name="wizard_prev_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button> |
210 | | <button name="wizard_prev_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button> |
| 209 | <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button> |
| 210 | <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button> |
211 | 211 | {% endif %} |
212 | 212 | <input type="submit" value="{% trans "submit" %}"/> |
213 | 213 | </form> |