Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WizardView.get_cleaned_data_for_step updated to keep from re-validating steps #86

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions formtools/wizard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,16 +492,22 @@ def get_cleaned_data_for_step(self, step):
Returns the cleaned data for a given `step`. Before returning the
cleaned data, the stored values are revalidated through the form.
If the data doesn't validate, None will be returned.

Since wizard is initialized on each request, data is only
validated once per step for performance.
"""
if step in self.form_list:
form_obj = self.get_form(
step=step,
data=self.storage.get_step_data(step),
files=self.storage.get_step_files(step),
)
if form_obj.is_valid():
return form_obj.cleaned_data
return None
self.cleaned_data = getattr(self, 'cleaned_data', {})
if self.cleaned_data.get(step, None):
return self.cleaned_data[step]
else:
if step in self.form_list:
form_obj = self.get_form(step=step,
data=self.storage.get_step_data(step),
files=self.storage.get_step_files(
step))
if form_obj.is_valid():
self.cleaned_data[step] = form_obj.cleaned_data
return form_obj.cleaned_data

def get_next_step(self, step=None):
"""
Expand Down