Skip to content

Using MultiForm with Formset #51

Description

@quapka

I have a following setup:

SessionWizardView
  |_MultiForm (Step 1)
      |_forms.Form
      |_forms.ModelForm
      |_forms.BaseFormSet
  |_ Step 2
  ...

It sort of works, but I had to do one tweak on the forms.BaseFormSet:

@forms.BaseFormSet.cleaned_data.setter                                        
def cleaned_data(self, value):                                                
    # this setter is needed, because MultiForm sets cleaned_data during       
    # vallidation and it's not defined on BaseFormSet by default in Django 1.8
    for i, data in enumerate(value):                                          
        self.forms[i].cleaned_data = data                                     

because MultiForm sets the cleaned_data during its own cleaning.

The other issue I'm having is during tests. When I use

response = self.client.get(reverse(<SessionWizardView>))

then it's quite a digging, to get all the form data (management_form of the BaseFormSet). Would it be possible to make using BaseFormSet with MultiForm easier? I haven't checked the code, so I don't know myself, what would be needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions