InlineAdminForm
A wrapper around an inline form for use in the admin system.
Attributes
| Attribute | Type | Description |
|---|---|---|
| formset | [BaseInlineFormSet](../../../forms/models/baseinlineformset.md?sid=django_forms_models_baseinlineformset) | The parent formset instance that contains and manages this specific inline form. |
| model_admin | [ModelAdmin](../options/modeladmin.md?sid=django_contrib_admin_options_modeladmin) | The ModelAdmin instance responsible for the parent model's admin interface. |
| original | [Model](../../../db/models/base/model.md?sid=django_db_models_base_model) | The existing model instance being edited, or None if this is a new extra form. |
| show_url | boolean | A boolean flag indicating whether a link to the object's public view should be displayed. |
| absolute_url | string | The specific URL used for the 'View on site' link if applicable. |
Constructor
Signature
def InlineAdminForm(
formset: [BaseInlineFormSet](../../../forms/models/baseinlineformset.md?sid=django_forms_models_baseinlineformset),
form: [ModelForm](../../../forms/models/modelform.md?sid=django_forms_models_modelform),
fieldsets: list,
prepopulated_fields: dict,
original: [Model](../../../db/models/base/model.md?sid=django_db_models_base_model),
readonly_fields: list = None,
model_admin: [ModelAdmin](../options/modeladmin.md?sid=django_contrib_admin_options_modeladmin) = None,
view_on_site_url: str = None
)
Parameters
| Name | Type | Description |
|---|---|---|
| formset | [BaseInlineFormSet](../../../forms/models/baseinlineformset.md?sid=django_forms_models_baseinlineformset) | The formset instance containing the form. |
| form | [ModelForm](../../../forms/models/modelform.md?sid=django_forms_models_modelform) | The specific form instance being wrapped. |
| fieldsets | list | A list of fieldsets to be displayed. |
| prepopulated_fields | dict | A dictionary of fields that should be prepopulated. |
| original | [Model](../../../db/models/base/model.md?sid=django_db_models_base_model) | The model instance associated with the form, if it exists. |
| readonly_fields | list = None | A list of fields that should be rendered as read-only. |
| model_admin | [ModelAdmin](../options/modeladmin.md?sid=django_contrib_admin_options_modeladmin) = None | The ModelAdmin instance associated with the inline. |
| view_on_site_url | str = None | The URL for viewing the object on the live site. |
Methods
needs_explicit_pk_field()
@classmethod
def needs_explicit_pk_field() - > boolean
Determines if the form requires an explicit primary key field to be rendered, based on whether the PK is auto-generated, non-editable, or excluded from the form.
Returns
| Type | Description |
|---|---|
boolean | True if a primary key field must be explicitly included in the admin interface, False otherwise. |
pk_field()
@classmethod
def pk_field() - > [AdminField](adminfield.md?sid=django_contrib_admin_helpers_adminfield)
Wraps the model's primary key field in an AdminField instance for consistent rendering within the admin template.
Returns
| Type | Description |
|---|---|
[AdminField](adminfield.md?sid=django_contrib_admin_helpers_adminfield) | An AdminField object representing the primary key of the inline model. |
fk_field()
@classmethod
def fk_field() - > AdminField | string
Retrieves the foreign key field that links the inline model to its parent model.
Returns
| Type | Description |
|---|---|
| `AdminField | string` |
deletion_field()
@classmethod
def deletion_field() - > [AdminField](adminfield.md?sid=django_contrib_admin_helpers_adminfield)
Provides the checkbox field used to mark an inline record for deletion during a formset save operation.
Returns
| Type | Description |
|---|---|
[AdminField](adminfield.md?sid=django_contrib_admin_helpers_adminfield) | An AdminField instance representing the standard Django formset deletion field. |