Edit: After some re-writes of this post it is finally setup in a manor that is clean and failsafe.

After researching and setting up two FormWizards in Django I concluded some things that might be useful to others. Hence this post.

Having userdata available throughout the wizard

I’ve seen some solutions on the net for this but when you handle data from several models over different steps the best way to handle this is using Django’s session framework. In parse_params() in the beginning and end we repectively get/set data and store our data.

So whatever you do with the user data, it’s safe, and we can access it in any step throughout the wizardry.

You can imagine that in the parse_params() and the render_template() method you respectively have the ‘if current_step == ‘ or ‘if step == ‘ statements along the way. All having the wizdata dict available.

This also works in the done() method. Simply get the dict one last time from the user session.

Then, for tidyness, at the end of done() we remove the dict from the user session.

Gotchas

There can be stale data, in the form of our stored dicts, left behind when wizard sessions are not finished by the user. This also is true for the sessions itself. As stated in the The Django docs about sessions you should clean up the sessions from time to time.

Anybody that has improvements, questions or compliments please drop me a line :)

GrtzG