Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RESTful multi-step / multi-page forms in Django (ideas/examples)

What are some RESTful ways to transition between pages of a multi-page form in Django?

My current method:

  1. form POSTs to same page
  2. form view validates and stores POST data in session
  3. form view redirects to the next form page upon successful validation.
  4. next form checks if previous data exists. if not, redirects to first form.

Are redirects between form pages bad? Should forms POST to the next form page? If so, where should form validation happen?

like image 866
Ian Cohen Avatar asked Feb 15 '10 17:02

Ian Cohen


1 Answers

What you're doing sounds like an implementation of the PRG model for handling multi step forms.

You probably want to POST to the current step, and then redirect to the next step only if the form validates. There is no problem with redirecting between steps; in fact, as you probably discovered, it allows you to support the browser back button in your forms.

like image 165
tobias.mcnulty Avatar answered Nov 04 '22 19:11

tobias.mcnulty