formset_factory
Return a FormSet for the given form class.
def formset_factory(
form: type,
formset: type = BaseFormSet,
extra: int = 1,
can_order: bool = False,
can_delete: bool = False,
max_num: int = None,
validate_max: bool = False,
min_num: int = None,
validate_min: bool = False,
absolute_max: int = None,
can_delete_extra: bool = True,
renderer: object = None
) - > type
Return a FormSet for the given form class.
Parameters
| Name | Type | Description |
|---|---|---|
| form | type | The base form class that will be used to instantiate individual forms within the set. |
| formset | type = BaseFormSet | The base class from which the new FormSet class will inherit. |
| extra | int = 1 | The number of empty forms to display in addition to any initial data forms. |
| can_order | bool = False | Whether to provide an ordering field for each form to allow manual reordering. |
| can_delete | bool = False | Whether to provide a checkbox for each form to allow deletion of existing records. |
| max_num | int = None | The maximum number of forms that can be displayed or submitted. |
| validate_max | bool = False | If True, validation will fail if the number of forms exceeds max_num. |
| min_num | int = None | The minimum number of forms that must be submitted. |
| validate_min | bool = False | If True, validation will fail if the number of forms is less than min_num. |
| absolute_max | int = None | A hard limit on the number of forms instantiated to prevent memory-exhaustion attacks; must be greater than or equal to max_num. |
| can_delete_extra | bool = True | Whether extra forms are allowed to be marked for deletion. |
| renderer | object = None | The engine used to render the formset into HTML. |
Returns
| Type | Description |
|---|---|
type | A dynamically created FormSet class tailored to the provided form and configuration options. |