construct_instance
Construct and return a model instance from the bound form's cleaned_data, but do not save the returned instance to the database.
def construct_instance(
form: Form,
instance: Model,
fields: list = null,
exclude: list = null
) - > Model
Construct and return a model instance from the bound form's cleaned_data, but do not save the returned instance to the database.
Parameters
| Name | Type | Description |
|---|---|---|
| form | Form | The bound Django form instance containing the cleaned data to be applied to the model. |
| instance | Model | The existing Django model instance to be updated with the form data. |
| fields | list = null | An optional list of field names; if provided, only these fields will be updated on the instance. |
| exclude | list = null | An optional list of field names to be skipped during the instance update process. |
Returns
| Type | Description |
|---|---|
Model | The updated Django model instance populated with data from the form, but not yet persisted to the database. |