Django docs cover cleaning up and checking fields that are dependent on each other , but I can't find anything that covers forms that are dependent on each other.
I have one HTML form that contains both the standard django form and the django form. The correct check of each form in the form set is completely conditional based on the value from the main form (for example, check the box in the main form, and a special field in each form in the form set will suddenly become necessary).
My intuition is to “just” pass the entire main form into a form validation call, for example:
def my_view(request):
MyFormSet = formset_factory(MyForm, extra=2, can_order=True)
if request.method == 'POST':
form = MainForm(request.POST)
formset = MyFormSet(request.POST)
if form.is_valid() and formset.is_valid(form):
, , , formet is_valid(), is_valid() clean(). , .
?