django wizard -- How to realize a dynamic form(or formset) in wizard

1.1k views Asked by At

I have asked a similar question yesterday but perhaps it was too concret.

I have read a lot about this on net, but I didn't find any solution.

Here is what I want to realize:

  1. I want to implement a wizard which has 2 steps.

first step---ProductForm

Some fixed fields like Name, Description, etc

Then a dynamic field Picture which can be added by a button, that is to say if the user clicks add another picture, he should see a new Image field shown up

second step---MoreInfoForm

The user finishes the MoreInforForm, then we save the data.

Does anyone have an idea? Thanks in advance!

1

There are 1 answers

0
Timmy O'Mahony On

I just answered a similar question here:

django 1.3 wizard alter form_list to change next steps

You need to make two separate forms - a ProductForm and a MoreInfoForm - then you create a view to process these forms.

The view will check whether anything has been POSTed to it (i.e. a form has been submitted) and if so, decide if it needs to provide a new form (in the case of the ProductForm being submitted - i.e. step 1) or carry out a save (in the case that the MoreInfoForm has been submitted - i.e. step 2)

If there is data in the first form that you need to hold onto until the second form has been filled out, you can save this data in a session variable.