Skip to main content

ModelFormMetaclass

This class is a metaclass used to create form classes that are tied to database models. It automatically extracts and configures form fields based on the model's definition, handling metadata options such as field inclusion, exclusion, and custom widgets. The metaclass also validates the configuration of the form's inner Meta class to ensure proper field mapping and error handling.

Attributes

AttributeTypeDescription
_meta[ModelFormOptions](modelformoptions.md?sid=django_forms_models_modelformoptions)An instance of ModelFormOptions containing the configuration extracted from the inner Meta class of the form.
base_fieldsdictA dictionary mapping field names to form field instances, generated by combining model-derived fields and explicitly declared fields.