2π
β
It can be achieved as follows:
- Overwrite the get_form_initial(self, step) method of the wizard. Handle the later step as follows:
- retrieve the cleaned data of the earlier step;
- retrieve the initial data for this step (super call);
- merge the two dictionaries and return the result;
- In the clean method of the later form access the data of the earlier form via the self.initial field.
Code snippet for the Wizard class:
def get_form_initial(self, step):
if step == '5':
step4 = self.get_cleaned_data_for_step('3')
res = super(DenovoPatternWizard, self).get_form_initial(step)
res['extendsequencedb'] = {}
res['extendsequencedb']['include_most_similar_pattern_sequences'] = step4['sequencepatternassignment'][
'number_sites_per_pattern']
return res
Code snippet of the later form:
def clean(self):
cleaned_data = super(InputDenovoPatternPatternForm, self).clean()
# compatibility of earlier and current step
if self.initial['timeseries_data'].number_timepoints != cleaned_data['pattern_data'].number_timepoints:
raise ValidationError("The time-series and pattern input files need to have the same number of timepoints (%d and %d respectively)." %
(self.initial['timeseries_data'].number_timepoints, cleaned_data['pattern_data'].number_timepoints))
π€derwiwie
Source:stackexchange.com