Refresh Django wizard form after browser's back button

345 Views Asked by At

I am using SessionWizardView from django-formtools project. I've noticed that after successfully passing all form checks and executing done() function, which redirects to completely different view, user can still hit browser Back button and re-fill form again. Isn't there any way to prevent that? I would assume that it would be some kind of session cleaning mechanism. But I cannot find any in documentation.

1

There are 1 best solutions below

0
On

After some playing around I've found that it can be achieved in two lines:

def done(self, form_list, form_dict, **kwargs):
    #regular form processing
    self.instance_dict = None
    self.storage.reset()

Now, after pressing Back button and submitting form it fails because no data exists and resets to first screen.