Documentation for form wizard -> get_form()
|Reported by:||tris@…||Owned by:||nobody|
|Has patch:||no||Needs documentation:|
|Needs tests:||Patch needs improvement:|
The description for this method mentions that 'If no step is defined, the current step will be determined automatically' but the example fails to allow for this.
This is an issue as when validation fails for a step then the method is called with step=None and the custom code will not be executed - in my case I was filtering ModelChoice fields based on the answers to the previous form and was losing my filters.
The example should be:
def get_form(self, step=None, data=None, files=None): form = super(MyWizard, self).get_form(step, data, files) if step is None: step = self.steps.current if step == '1': form.user = self.request.user return form