views.py
FORMS = [("customer", CustomerModelForm),
("supplier", SupplierModelForm),
("brand", BrandMasterModelForm)]
TEMPLATES = {"customer": "add_customer.html",
"supplier": "supplier_master",
"brand": "add_brand.html"}
class MultiStepWizard(SessionWizardView):
def get_template_names(self):
return [TEMPLATES[self.steps.current]]
def done(self, form_list, **kwargs):
form_data = [form.cleaned_data for form in form_list]
return render(self.request, "dashboard_inventory.html", {"data":form_data})
urls.py
path('manage_sales/', MultiStepWizard.as_view(FORMS), name="MultiStepWizard")
forms.py
class CustomerModelForm(forms.ModelForm):
class Meta:
model = Customer
fields = ('name','address','contact','email','state','gstin','pan')
class SupplierModelForm(forms.ModelForm):
class Meta:
model = Supplier
fields = ('name','address','city','manager','contact')
widgets = {
'name':forms.TextInput(attrs={'class': 'form-control'}),
'address':forms.TextInput(attrs={'class': 'form-control'}),
'city':forms.TextInput(attrs={'class': 'form-control'}),
'manager':forms.TextInput(attrs={'class': 'form-control'}),
'contact':forms.TextInput(attrs={'class': 'form-control'}),
}
class BrandMasterModelForm(forms.ModelForm):
class Meta:
model = BrandMaster
fields=('brand_name', 'suppliername')
widgets={'brand_name':forms.TextInput(attrs={'class': 'form-control'}),'suppliername':forms.Select(attrs={'id':'choicewa','class': 'form-control','required': 'true'}),
}
I'm trying to use formtool to save multistep forms with my own templates. But I am getting error
ManagementForm data is missing or has been tampered Django FormTools Wizard
While saving first form, then unable to proceed further.
You need to add below line in html form
{{ wizard.management_form }}