Combining a Form and a FormSet in Django

2019-09-01 14:51发布

I have a FormWizard that displays three parts of a registration application. The last part involves creating a group and adding members to it. I would like to present two forms at once on the same view.

Group Builder

class GroupBuilder(forms.Form):
    name = forms.CharField(max_length=30,
                       widget=forms.TextInput(attrs={
                       'placeholder': 'eg. The Underdogs'}))

Member Builder

class MemberBuilder(forms.Form):
    first_name = forms.CharField(max_length=128)
    last_name = forms.CharField(max_length=128)
    role = forms.CharField(max_length=128)

How can I present the GroupBuilder Form and a StudentBuilder formset at once?

0条回答
登录 后发表回答