InlineAdminFormSet
A wrapper around an inline formset for use in the admin system.
Attributes
| Attribute | Type | Description |
|---|---|---|
| opts | [InlineModelAdmin](../options/inlinemodeladmin.md?sid=django_contrib_admin_options_inlinemodeladmin) | The inline options object containing configuration for the inline admin model. |
| formset | [BaseInlineFormSet](../../../forms/models/baseinlineformset.md?sid=django_forms_models_baseinlineformset) | The underlying Django formset instance being wrapped for admin display. |
| fieldsets | list | A list of fieldset configurations defining how fields are grouped and displayed in the forms. |
| model_admin | [ModelAdmin](../options/modeladmin.md?sid=django_contrib_admin_options_modeladmin) | The parent ModelAdmin instance that contains this inline formset. |
| readonly_fields | tuple = () | A collection of field names that should be rendered as non-editable text. |
| prepopulated_fields | dict = {} | A dictionary mapping field names to the fields from which they should automatically populate. |
| classes | string | A space-separated string of CSS classes derived from the inline options for styling the formset container. |
| has_add_permission | boolean = True | A boolean flag indicating whether the user is allowed to add new records within this inline. |
| has_change_permission | boolean = True | A boolean flag indicating whether the user is allowed to modify existing records within this inline. |
| has_delete_permission | boolean = True | A boolean flag indicating whether the user is allowed to remove records within this inline. |
| has_view_permission | boolean = True | A boolean flag indicating whether the user is allowed to view the records within this inline. |
Constructor
Signature
def InlineAdminFormSet(
inline: Any,
formset: Any,
fieldsets: list,
prepopulated_fields: dict = None,
readonly_fields: tuple = None,
model_admin: Any = None,
has_add_permission: boolean = True,
has_change_permission: boolean = True,
has_delete_permission: boolean = True,
has_view_permission: boolean = True
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| inline | Any | The inline admin options object. |
| formset | Any | The formset instance being wrapped. |
| fieldsets | list | The fieldset definitions for the inline forms. |
| prepopulated_fields | dict = None | A dictionary mapping field names to the fields they should be prepopulated from. |
| readonly_fields | tuple = None | A list of fields that should be rendered as read-only. |
| model_admin | Any = None | The ModelAdmin instance associated with the parent model. |
| has_add_permission | boolean = True | Whether the user has permission to add new inline records. |
| has_change_permission | boolean = True | Whether the user has permission to change existing inline records. |
| has_delete_permission | boolean = True | Whether the user has permission to delete inline records. |
| has_view_permission | boolean = True | Whether the user has permission to view inline records. |
Methods
fields()
@classmethod
def fields() - > generator
Generates metadata for each field in the formset, including labels, help texts, and widget information, while excluding the foreign key to the parent model.
Returns
| Type | Description |
|---|---|
generator | A generator yielding dictionaries containing field attributes like name, label, widget, and requirement status. |
inline_formset_data()
@classmethod
def inline_formset_data() - > string
Produces a JSON-encoded string containing configuration data for the JavaScript inline formset handler, such as the prefix and localized action text.
Returns
| Type | Description |
|---|---|
string | A JSON string used by the admin frontend to initialize dynamic formset behavior. |
forms()
@classmethod
def forms() - > list
Provides access to the underlying list of form instances managed by the wrapped formset.
Returns
| Type | Description |
|---|---|
list | A list of Django Form instances belonging to the formset. |
is_collapsible()
@classmethod
def is_collapsible() - > boolean
Determines if the inline interface should be rendered as a collapsible element based on CSS classes and the absence of validation errors.
Returns
| Type | Description |
|---|---|
boolean | True if the 'collapse' class is present and there are no formset errors; otherwise False. |
non_form_errors()
@classmethod
def non_form_errors() - > [ErrorList](../../../forms/utils/errorlist.md?sid=django_forms_utils_errorlist)
Retrieves errors that are not associated with a specific form, such as cross-form validation failures.
Returns
| Type | Description |
|---|---|
[ErrorList](../../../forms/utils/errorlist.md?sid=django_forms_utils_errorlist) | A collection of errors that apply to the formset as a whole. |
is_bound()
@classmethod
def is_bound() - > boolean
Indicates whether the underlying formset has been bound to submitted data for validation.
Returns
| Type | Description |
|---|---|
boolean | True if the formset was initialized with POST or GET data; False otherwise. |
total_form_count()
@classmethod
def total_form_count() - > integer
Calculates the total number of forms in the formset, including initial, extra, and newly added forms.
Returns
| Type | Description |
|---|---|
integer | The count of all forms currently managed by the formset. |
media()
@classmethod
def media() - > [Media](../../../forms/widgets/media.md?sid=django_forms_widgets_media)
Aggregates all required JavaScript and CSS assets from the inline options, the formset, and the individual admin forms.
Returns
| Type | Description |
|---|---|
[Media](../../../forms/widgets/media.md?sid=django_forms_widgets_media) | A Django Media object containing the combined assets for the inline interface. |