class documentation

The main implementation of all the Form logic. Note that this class is different than Form. See the comments by the Form class for more info. Any improvements to the form API should be made to this class, not to the Form class.

Method __getitem__ Return a BoundField with the given name.
Method __init__ Undocumented
Method __iter__ Yield the form's fields as BoundField objects.
Method __repr__ Undocumented
Method add_error Update the content of `self._errors`.
Method add_initial_prefix Add an 'initial' prefix for checking dynamic initial values.
Method add_prefix Return the field name with a prefix appended, if this Form has a prefix set.
Method clean Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named '__all__'.
Method full_clean Clean all of self.data and populate self._errors and self.cleaned_data.
Method get_context Undocumented
Method get_initial_for_field Return initial data for field on form. Use initial data from the form or the field, in that order. Evaluate callable values.
Method has_changed Return True if data differs from initial.
Method has_error Undocumented
Method hidden_fields Return a list of all the BoundField objects that are hidden fields. Useful for manual form layout in templates.
Method is_multipart Return True if the form needs to be multipart-encoded, i.e. it has FileInput, or False otherwise.
Method is_valid Return True if the form has no errors, or False otherwise.
Method non_field_errors Return an ErrorList of errors that aren't associated with a particular field -- i.e., from Form.clean(). Return an empty ErrorList if there are none.
Method order_fields Rearrange the fields according to field_order.
Method visible_fields Return a list of BoundField objects that aren't hidden fields. The opposite of the hidden_fields() method.
Class Variable default_renderer Undocumented
Class Variable field_order Undocumented
Class Variable template_name_div Undocumented
Class Variable template_name_label Undocumented
Class Variable template_name_p Undocumented
Class Variable template_name_table Undocumented
Class Variable template_name_ul Undocumented
Instance Variable auto_id Undocumented
Instance Variable cleaned_data Undocumented
Instance Variable data Undocumented
Instance Variable empty_permitted Undocumented
Instance Variable error_class Undocumented
Instance Variable fields Undocumented
Instance Variable files Undocumented
Instance Variable initial Undocumented
Instance Variable is_bound Undocumented
Instance Variable label_suffix Undocumented
Instance Variable prefix Undocumented
Instance Variable renderer Undocumented
Instance Variable use_required_attribute Undocumented
Property changed_data Undocumented
Property errors Return an ErrorDict for the data provided for the form.
Property media Return all media required to render the widgets on this form.
Property template_name Undocumented
Method _bound_items Yield (name, bf) pairs, where bf is a BoundField object.
Method _clean_fields Undocumented
Method _clean_form Undocumented
Method _html_output Output HTML. Used by as_table(), as_ul(), as_p().
Method _post_clean An internal hook for performing additional cleaning after form cleaning is complete. Used for model validation in model forms.
Method _widget_data_value Undocumented
Instance Variable _bound_fields_cache Undocumented
Instance Variable _errors Undocumented

Inherited from RenderableFormMixin:

Method as_div Render as <div> elements.
Method as_p Render as <p> elements.
Method as_table Render as <tr> elements excluding the surrounding <table> tag.
Method as_ul Render as <li> elements excluding the surrounding <ul> tag.

Inherited from RenderableMixin (via RenderableFormMixin):

Method render Undocumented
def __getitem__(self, name): (source)

Return a BoundField with the given name.

def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None): (source)
def __iter__(self): (source)

Yield the form's fields as BoundField objects.

def __repr__(self): (source)

Undocumented

def add_error(self, field, error): (source)

Update the content of `self._errors`. The `field` argument is the name of the field to which the errors should be added. If it's None, treat the errors as NON_FIELD_ERRORS. The `error` argument can be a single error, a list of errors, or a dictionary that maps field names to lists of errors. An "error" can be either a simple string or an instance of ValidationError with its message attribute set and a "list or dictionary" can be an actual `list` or `dict` or an instance of ValidationError with its `error_list` or `error_dict` attribute set. If `error` is a dictionary, the `field` argument *must* be None and errors will be added to the fields that correspond to the keys of the dictionary.

def add_initial_prefix(self, field_name): (source)

Add an 'initial' prefix for checking dynamic initial values.

def add_prefix(self, field_name): (source)

Return the field name with a prefix appended, if this Form has a prefix set. Subclasses may wish to override.

def clean(self): (source)

Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named '__all__'.

def full_clean(self): (source)

Clean all of self.data and populate self._errors and self.cleaned_data.

def get_context(self): (source)
def get_initial_for_field(self, field, field_name): (source)

Return initial data for field on form. Use initial data from the form or the field, in that order. Evaluate callable values.

def has_changed(self): (source)

Return True if data differs from initial.

def has_error(self, field, code=None): (source)

Undocumented

def hidden_fields(self): (source)

Return a list of all the BoundField objects that are hidden fields. Useful for manual form layout in templates.

def is_multipart(self): (source)

Return True if the form needs to be multipart-encoded, i.e. it has FileInput, or False otherwise.

def is_valid(self): (source)

Return True if the form has no errors, or False otherwise.

def non_field_errors(self): (source)

Return an ErrorList of errors that aren't associated with a particular field -- i.e., from Form.clean(). Return an empty ErrorList if there are none.

def order_fields(self, field_order): (source)

Rearrange the fields according to field_order. field_order is a list of field names specifying the order. Append fields not included in the list in the default order for backward compatibility with subclasses not overriding field_order. If field_order is None, keep all fields in the order defined in the class. Ignore unknown fields in field_order to allow disabling fields in form subclasses without redefining ordering.

def visible_fields(self): (source)

Return a list of BoundField objects that aren't hidden fields. The opposite of the hidden_fields() method.

default_renderer = (source)

Undocumented

template_name_div: str = (source)

Undocumented

template_name_label: str = (source)

Undocumented

template_name_p: str = (source)

Undocumented

template_name_table: str = (source)

Undocumented

template_name_ul: str = (source)

Undocumented

Undocumented

cleaned_data: dict = (source)

Undocumented

Undocumented

empty_permitted = (source)

Undocumented

error_class = (source)

Undocumented

Undocumented

Undocumented

is_bound = (source)

Undocumented

label_suffix = (source)

Undocumented

Undocumented

renderer = (source)

Undocumented

use_required_attribute = (source)

Undocumented

Return an ErrorDict for the data provided for the form.

Return all media required to render the widgets on this form.

@property
template_name = (source)

Undocumented

def _bound_items(self): (source)

Yield (name, bf) pairs, where bf is a BoundField object.

def _clean_fields(self): (source)

Undocumented

def _clean_form(self): (source)

Undocumented

def _html_output(self, normal_row, error_row, row_ender, help_text_html, errors_on_separate_row): (source)

Output HTML. Used by as_table(), as_ul(), as_p().

def _post_clean(self): (source)

An internal hook for performing additional cleaning after form cleaning is complete. Used for model validation in model forms.

def _widget_data_value(self, widget, html_name): (source)

Undocumented

_bound_fields_cache: dict = (source)

Undocumented

Undocumented