I have a django model like this:
class Something(models.Model):
attr1 = models.IntegerField()
attr2 = models.IntegerField()
attr3 = models.IntegerField()
And I want to make a form to create Something objects, but I want to do it using a WizardForm, so I split the ‘big form’ into two forms, like this:
class Form1(forms.ModelForm):
class Meta:
model = Something
exclude = ('atrr3',)
class Form2(forms.ModelForm):
class Meta:
model = Something
fields = ('atrr3',)
So both together make the complete model form.
So here goes my question: is there a way to save them both together and create a single Something object out of them?
After a lot of googling I found the answer to my question. I’ll post it for anyone that has the same problem:
If you have more than one form and you need to combine them to create objects of a model, you can do something like this:
I think is a simple and pretty good solution.