Question

I have a Django form which is a modelForm:

class EducationForm(ModelForm):
    class Meta:
        model = Education

But it is actually used as a formset:

queryset_education = Education.objects.filter(member = edit_member)
EducationFormSet = modelformset_factory(Education, form = EducationForm)
form_education  = EducationFormSet(queryset = queryset_education)

How can I force the first form to be required? I saw some similar questions in StackOverflow... none helped me, as I don't have a class that inherit from BaseFormSet (Should I create one?)

Thanks!

Tidhar

Was it helpful?

Solution

Yes, you should define a formset class with a clean method, and pass that in as the formset argument to modelformset_factory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top