2๐
I solved this by overriding get_form_kwargs for the WizardView. It normally just returns an empty dictionary that get_form populates, so by overriding it to return a dictionary with the data you need prepopulated, you can pass kwargs to your form init.
def get_form_kwargs(self, step=None):
kwargs = {}
if step == '1':
your_data = self.get_cleaned_data_for_step('0')['your_data']
kwargs.update({'your_data': your_data,})
return kwargs
Then, in your form init method you can just pop the kwarg off before calling super:
self.your_data = kwargs.pop('your_data', None)
and use that value to perform whatever logic you need to on the form.
๐คNick Gottlieb
0๐
๐คVoSi
- [Answered ]-Django 1.8 PUT and DELETE method simple implementation
- [Answered ]-Django forms โ dictionary and lists
- [Answered ]-Django, abstract model class + derived model & form "exclude" field issue
- [Answered ]-Is there a way to rewrite this apparently simple Django snippet so that it doesn't hit the database so much?
- [Answered ]-Django receivers best practice
Source:stackexchange.com