Search code examples
djangohttp-redirectformwizard

Django FormWizard - show summary when done


I am using Django's FormWizard for a multi-step form and as a last step (after saving the data) I would like to show a summary of the previously entered form data.

I can achieve this by overriding the done() method like this:

def done(self, form_list, **kwargs):
    info = self.save_info(form_list[0])
    extra = self.save_extra(info, form_list[1])
    # how to provide context for redirect?
    # return redirect('confirmation.html')
    # this works, but uses POST
    return render_to_response(
        'confirmation.html',
        {'form_list': [form.cleaned_data for form in form_list]},
        context_instance=RequestContext(self.request)
    ) 

Instead of calling the confirmation via POST I would like to use a redirect (browser back button). But I am not sure how to pass on the form_list to the view/template since redirects don't take a context. Any ideas if there is a clean standard way of doing this?

Note: The data is entered by an anonymous user. So the saved data and the user are not associated.


Solution

  • You could also save the formdata in a session, and retrieve that info when calling the confirmation.html view.

    If you use this I would advise to set SESSION_EXPIRE_AT_BROWSER_CLOSE = True or an expire time for the session.