Search code examples
pythondjangodjango-formwizard

Formwizards for editing in Django


I am in the process of making a webapp, and this webapp needs to have a form wizard. The wizard consists of 3 ModelForms, and it works flawlessly. But I need the second form to be a "edit form". That is, i need it to be a form that is passed an instance.

How can you do this with a form wizard? How do you pass in an instance of a model? I see that the FormWizard class has a get_form method, but isnt there a documented way to use the formwizard for editing/reviewing of data?


Solution

  • In Django 1.4 you can do something like:

    def edit(request):
        initial = {
           0: {'subject': 'Hello', 'sender': '[email protected]'},
           1: {'message': 'Hi there!'}
           }
        wiz = FormWizard([form1,form2,form3],initial_dict = initial)
        return wiz(request)