Skip to main content

ManagementForm

Keep track of how many form instances are displayed on the page. If adding new forms via JavaScript, you should increment the count field of this form as well.

Attributes

AttributeTypeDescription
TOTAL_FORMS[IntegerField](../fields/integerfield.md?sid=django_forms_fields_integerfield)Tracks the total number of form instances displayed on the page, including both initial and extra forms.
INITIAL_FORMS[IntegerField](../fields/integerfield.md?sid=django_forms_fields_integerfield)Tracks the number of form instances that were initially loaded with data from the database.
MIN_NUM_FORMS[IntegerField](../fields/integerfield.md?sid=django_forms_fields_integerfield)Provides the minimum number of forms required for the formset, primarily for use by client-side JavaScript validation.
MAX_NUM_FORMS[IntegerField](../fields/integerfield.md?sid=django_forms_fields_integerfield)Provides the maximum number of forms allowed in the formset, primarily for use by client-side JavaScript validation.

Methods


clean()

@classmethod
def clean() - > dict

Validates the management form data and ensures that total and initial form counts have fallback values of 0 if the form is invalid. This prevents errors in the formset processing logic when submitted data is missing or corrupted.

Returns

TypeDescription
dictA dictionary of validated form data containing at least the TOTAL_FORMS and INITIAL_FORMS counts.