You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using SessionWizardView which has 3 forms. The forms are all using the same template, which has 3 fields, one of which is a required UUID for a part. The end result is to have 3 unique parts (i.e. UUID must be ... unique). I have validation in my form clean method that checks this. The validation works as expected if the user never refreshes:
User enters UUID "abc" in step 0 and submits
User enters UUID "xyz" in step 1 and submits
User enters UUID "abc" in step 2 and submits
form.is_valid() fails
User sees a validation message about non unique UUID
User is still on step 2
Reproduce
User enters UUID "abc" in step 0 and submits
User is on step 1 and refreshes the page
Expected behavior
User is still on step 1
Actual behavior
Page refresh sends a POST request with data from step 0
formwizard thinks user is on step 0 and has entered "abc"
form.is_valid() fails
User sees a validation message about non unique UUID
User is returned to step 0
This poses a problem for the user because now they are stuck. They have to enter 3 parts and there is no way to remove the barcode "abc" from the formwizard data. Now that the user is back on step 0, there will be no way for them to enter 3 distinct UUID, it will always think one of them is duplicated after step 1.
Diagnosis
I've traced the problem to this bit of code in the post method for WizardView:
form_current_step=management_form.cleaned_data['current_step']
if (form_current_step!=self.steps.currentandself.storage.current_stepisnotNone):
# form refreshed, change current stepself.storage.current_step=form_current_step
In the following, the conditional storage.current_step is not None is always True
Step
Action
Unique UUID?
storage.current_step
form_current_step
storage.current_step changed
0
submit
yes
0
0
No (0)
1
refresh
n/a
1
0
Yes (1 -> 0)
1
submit
no
1
1
No (1)
It seems to me that we shouldn't be changing the current step when the page is refreshed. I'm not sure if this is expected/designed behavior or if this is a bug.
Thank you in advance for your time.
The text was updated successfully, but these errors were encountered:
Scenario
I am using
SessionWizardView
which has 3 forms. The forms are all using the same template, which has 3 fields, one of which is a required UUID for a part. The end result is to have 3 unique parts (i.e. UUID must be ... unique). I have validation in my formclean
method that checks this. The validation works as expected if the user never refreshes:form.is_valid()
failsReproduce
Expected behavior
Actual behavior
formwizard
thinks user is on step 0 and has entered "abc"form.is_valid()
failsThis poses a problem for the user because now they are stuck. They have to enter 3 parts and there is no way to remove the barcode "abc" from the
formwizard
data. Now that the user is back on step 0, there will be no way for them to enter 3 distinct UUID, it will always think one of them is duplicated after step 1.Diagnosis
I've traced the problem to this bit of code in the
post
method forWizardView
:In the following, the conditional
storage.current_step is not None
is alwaysTrue
storage.current_step
form_current_step
storage.current_step
changedIt seems to me that we shouldn't be changing the current step when the page is refreshed. I'm not sure if this is expected/designed behavior or if this is a bug.
Thank you in advance for your time.
The text was updated successfully, but these errors were encountered: