Question

I need to make a two form wizard. In one form I need to gather some data, process that and prepopulate a field in the second form. What's the best/easiest way to do it?

Was it helpful?

Solution

Add get_form_initial() method in your wizard class, for the 2nd step, use data from first step using get_cleaned_data_for_step().

Something like:

class myWizardView:

    def get_form_initial(self, step):
        if int(step) == 1:
            # get cleaned data from prev step
            return self.get_cleaned_data_for_step(str(int(step) - 1))

You may want to manipulate the dict to have appropriate attribute names etc.

More reference at Form Wizard

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top