User submits form one.
Form one is used as seed info for form 2 form_factory
Using django form wizard after 3 hours of attempting to coax the stock Django 1.3 to use a form factory.
I’m trying to figure out how to seed this information. I have the information – I just don’t know where to stick it. (Oh I have ideas..)
–urls.py–
url(r'homes/bulk/$',
BulkHomeWizard.as_view([('home_0', BulkUploadFormOne),
('home_1', formset_factory(BulkUploadFormTwo, extra=1))])
–views.py–
class BulkHomeWizard(SessionWizardView):
def get_context_data(self, form, **kwargs):
context = super(BulkHomeWizard, self).get_context_data(form, **kwargs)
self.template_name = 'axis/bulk_%s.html' % self.steps.current
if self.steps.current == 'home_1':
data = self.get_cleaned_data_for_step('home_0')
# OK I have the data.. Now I thought I could simply pass the form back in....
HomeFormSet = formset_factory(BulkUploadFormTwo, extra=0)
form = HomeFormSet(initial=data['homes'])
context.update({'form': form})
return context
If anyone knows these new form wizards would you mind giving me a once over. I’m sure it’s simple…
The key is SessionWizardView… This is in the development branch of Django and won’t be released until 1.4. You can of course download the development branch and use the SessionWizardView but this isn’t recommended for production code!
The older version of the forms wizard for 1.3 is documented here. It does much less (hence the new version) and basically passes everything around as hidden fields.