Skip to main content

InlineAdminFormSet

A wrapper around an inline formset for use in the admin system.

Attributes

AttributeTypeDescription
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.
fieldsetslistA 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_fieldstuple = ()A collection of field names that should be rendered as non-editable text.
prepopulated_fieldsdict = {}A dictionary mapping field names to the fields from which they should automatically populate.
classesstringA space-separated string of CSS classes derived from the inline options for styling the formset container.
has_add_permissionboolean = TrueA boolean flag indicating whether the user is allowed to add new records within this inline.
has_change_permissionboolean = TrueA boolean flag indicating whether the user is allowed to modify existing records within this inline.
has_delete_permissionboolean = TrueA boolean flag indicating whether the user is allowed to remove records within this inline.
has_view_permissionboolean = TrueA 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

NameTypeDescription
inlineAnyThe inline admin options object.
formsetAnyThe formset instance being wrapped.
fieldsetslistThe fieldset definitions for the inline forms.
prepopulated_fieldsdict = NoneA dictionary mapping field names to the fields they should be prepopulated from.
readonly_fieldstuple = NoneA list of fields that should be rendered as read-only.
model_adminAny = NoneThe ModelAdmin instance associated with the parent model.
has_add_permissionboolean = TrueWhether the user has permission to add new inline records.
has_change_permissionboolean = TrueWhether the user has permission to change existing inline records.
has_delete_permissionboolean = TrueWhether the user has permission to delete inline records.
has_view_permissionboolean = TrueWhether 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

TypeDescription
generatorA 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

TypeDescription
stringA 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

TypeDescription
listA 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

TypeDescription
booleanTrue 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

TypeDescription
[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

TypeDescription
booleanTrue 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

TypeDescription
integerThe 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

TypeDescription
[Media](../../../forms/widgets/media.md?sid=django_forms_widgets_media)A Django Media object containing the combined assets for the inline interface.