diff --git a/django/contrib/formtools/wizard/tests/formtests.py b/django/contrib/formtools/wizard/tests/formtests.py
index 111981f..93f6b5f 100644
a
|
b
|
class Step2(forms.Form):
|
35 | 35 | class Step3(forms.Form): |
36 | 36 | data = forms.CharField() |
37 | 37 | |
| 38 | class CustomKwargsForm(forms.Form): |
| 39 | name = forms.CharField() |
| 40 | |
| 41 | def __init__(self, test=None, *args, **kwargs): |
| 42 | return super(CustomKwargsForm, self).__init__(*args, **kwargs) |
| 43 | |
38 | 44 | class UserForm(forms.ModelForm): |
39 | 45 | class Meta: |
40 | 46 | model = User |
… |
… |
class TestWizard(WizardView):
|
48 | 54 | response = super(TestWizard, self).dispatch(request, *args, **kwargs) |
49 | 55 | return response, self |
50 | 56 | |
| 57 | def get_form_kwargs(self, step, **kwargs): |
| 58 | kwargs = super(TestWizard, self).get_form_kwargs(step, **kwargs) |
| 59 | if step == 'kwargs_test': |
| 60 | kwargs['test'] = True |
| 61 | return kwargs |
| 62 | |
51 | 63 | class FormTests(TestCase): |
52 | 64 | def test_form_init(self): |
53 | 65 | testform = TestWizard.get_initkwargs([Step1, Step2]) |
… |
… |
class FormTests(TestCase):
|
102 | 114 | response, instance = testform(request) |
103 | 115 | self.assertEquals(instance.get_next_step(), 'step3') |
104 | 116 | |
| 117 | def test_form_kwargs(self): |
| 118 | request = get_request() |
| 119 | |
| 120 | testform = TestWizard.as_view([('start', Step1), |
| 121 | ('kwargs_test', CustomKwargsForm)]) |
| 122 | response, instance = testform(request) |
| 123 | |
| 124 | self.assertTrue('test' not in instance.get_form_kwargs('start')) |
| 125 | self.assertTrue('test' in instance.get_form_kwargs('kwargs_test')) |
| 126 | |
105 | 127 | def test_form_prefix(self): |
106 | 128 | request = get_request() |
107 | 129 | |
diff --git a/django/contrib/formtools/wizard/views.py b/django/contrib/formtools/wizard/views.py
index ac9cfbd..f458900 100644
a
|
b
|
class WizardView(TemplateView):
|
366 | 366 | if step is None: |
367 | 367 | step = self.steps.current |
368 | 368 | # prepare the kwargs for the form instance. |
| 369 | kwargs = self.get_form_kwargs(step, data=data, files=files) |
| 370 | return self.form_list[step](**kwargs) |
| 371 | |
| 372 | def get_form_kwargs(self, step, data=None, files=None): |
| 373 | """ |
| 374 | Returns the keyword arguments for instantiating the form (or formset) |
| 375 | on given step. |
| 376 | """ |
369 | 377 | kwargs = { |
370 | 378 | 'data': data, |
371 | 379 | 'files': files, |
… |
… |
class WizardView(TemplateView):
|
378 | 386 | elif issubclass(self.form_list[step], forms.models.BaseModelFormSet): |
379 | 387 | # If the form is based on ModelFormSet, add queryset if available. |
380 | 388 | kwargs.update({'queryset': self.get_form_instance(step)}) |
381 | | return self.form_list[step](**kwargs) |
| 389 | return kwargs |
382 | 390 | |
383 | 391 | def process_step(self, form): |
384 | 392 | """ |