Friday, October 26, 2012

Re: Save formtools.WizardView for later completion in another session?

I also came across this issue. I managed to address this by actually looking at the code for django.contrib.formtools.wizard.views.WizardView. 

(I am no django expert. So I am sure there might be a cleaner way. This worked for me. So I am just sharing my experience.)

I overrode the get and render_done method of SessionWizardView. The session data is saved in a dictionary called storage.data. It is initialized in the get method and destroyed in render_done method. 

So I created a model in my database to hold: an id and a text field which holds the json version of storage.data.

To save the session data, place a hook in render_done method to save the data to the model and generate an id.

To restore the session, pass the id as a parameter to the form wizard. I've put some sample code here: https://gist.github.com/3959900

Cheers


On Tuesday, 2 October 2012 16:26:57 UTC+1, Alex S-B. wrote:
I have a long multi-page form wizard (a django.contrib.formtools.wizard.views.SessionWizardView) that I would like the user to be able to continue working through even after logging out and back in from a different computer. That is, I would like the wizard data to persist across sessions until completed. Are there any examples of how to do this? Is this best approach to write my own custom storage backend?

Thanks!
Alex


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/jBXw6R8knNgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment