Forms

Forms for creating and modifying database objects. Please refer to django.forms for general information about Django forms (see also: Working with forms).

Custom Content Model Form

class integreat_cms.cms.forms.custom_content_model_form.CustomContentModelForm(**kwargs: Any)[source]

Bases: CustomModelForm

Form for the content model forms for pages, events and POIs.

Form fields:

Parameters:

kwargs (Any)

__init__(**kwargs: Any) None[source]

Initialize custom content model form

Parameters:

**kwargs (Any) – The supplied keyword arguments

Return type:

None

add_error(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.

add_error_messages(request: HttpRequest) None[source]

This function accepts the current request and adds the form’s error messages to the message queue of django.contrib.messages.

Parameters:

request (HttpRequest) – The current request submitting the form

Return type:

None

add_initial_prefix(field_name)[source]

Add an ‘initial’ prefix for checking dynamic initial values.

add_prefix(field_name)[source]

Return the field name with a prefix appended, if this Form has a prefix set.

Subclasses may wish to override.

add_success_message(request: HttpRequest) None[source]

This adds a success message for a translation form. Requires the attributes “title”, “status” and “foreign_object” on the form instance.

Parameters:

request (HttpRequest) – The current request submitting the translation form

Return type:

None

as_div()[source]

Render as <div> elements.

as_p()[source]

Render as <p> elements.

as_table()[source]

Render as <tr> elements excluding the surrounding <table> tag.

as_ul()[source]

Render as <li> elements excluding the surrounding <ul> tag.

changed_data[source]
clean() dict[str, Any][source]

This method extends the clean()-method to verify that a user can modify this content model

Returns:

The cleaned data (see Overriding the clean() method)

Return type:

dict[str, Any]

clean_content() str[source]

Validate the content field (see Overriding the clean() method) and applies changes to any element to match the guidelines.

Raises:

ValidationError – When a heading 1 (<h1>) is used in the text content

Returns:

The valid content

Return type:

str

clean_slug() str[source]

Validate the slug field (see Overriding the clean() method)

Returns:

A unique slug based on the input value

Return type:

str

default_renderer = None[source]
property errors[source]

Return an ErrorDict for the data provided for the form.

field_order = None[source]
full_clean()[source]

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

get_context()[source]
get_error_messages() list[dict[str, str]][source]

Return all error messages of this form and append labels to field-errors

Returns:

The errors of this form

Return type:

list[dict[str, str]]

get_initial_for_field(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.

has_changed()[source]

Return True if data differs from initial.

has_error(field, code=None)[source]
hidden_fields()[source]

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

is_multipart()[source]

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

is_valid()[source]

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

property media[source]

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

non_field_errors()[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.

order_fields(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.

prefix = None[source]
render(template_name=None, context=None, renderer=None)[source]
save(commit: bool = True, foreign_form_changed: bool = False) Any[source]

This method extends the default save()-method of the base ModelForm to set attributes which are not directly determined by input fields.

Parameters:
  • commit (bool) – Whether or not the changes should be written to the database

  • foreign_form_changed (bool) – Whether or not the foreign form of this translation form was changed

Returns:

The saved content translation object

Return type:

Any

property template_name[source]
template_name_div = 'django/forms/div.html'[source]
template_name_label = 'django/forms/label.html'[source]
template_name_p = 'django/forms/p.html'[source]
template_name_table = 'django/forms/table.html'[source]
template_name_ul = 'django/forms/ul.html'[source]
use_required_attribute = True[source]
validate_unique()[source]

Call the instance’s validate_unique() method and update the form’s validation errors if any were raised.

visible_fields()[source]

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

Custom Filter Form

class integreat_cms.cms.forms.custom_filter_form.CustomFilterForm(**kwargs: Any)[source]

Bases: Form

Base class for filter forms

Form fields:

Parameters:

kwargs (Any)

__init__(**kwargs: Any) None[source]

Initialize the custom filter form

Parameters:

**kwargs (Any) – The supplied keyword arguments

Return type:

None

add_error(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.

add_initial_prefix(field_name)[source]

Add an ‘initial’ prefix for checking dynamic initial values.

add_prefix(field_name)[source]

Return the field name with a prefix appended, if this Form has a prefix set.

Subclasses may wish to override.

as_div()[source]

Render as <div> elements.

as_p()[source]

Render as <p> elements.

as_table()[source]

Render as <tr> elements excluding the surrounding <table> tag.

as_ul()[source]

Render as <li> elements excluding the surrounding <ul> tag.

changed_data[source]
clean()[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__’.

default_renderer = None[source]
property errors[source]

Return an ErrorDict for the data provided for the form.

field_order = None[source]
property filters_visible: bool[source]

This function determines whether the filter form is visible by default.

Returns:

Whether any filters (other than search) were changed

full_clean()[source]

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

get_context()[source]
get_initial_for_field(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.

has_changed()[source]

Return True if data differs from initial.

has_error(field, code=None)[source]
hidden_fields()[source]

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

property is_enabled: bool[source]

This function determines whether the filters are applied.

Returns:

Whether filtering should be performed

is_multipart()[source]

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

is_valid()[source]

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

property media[source]

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

non_field_errors()[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.

order_fields(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.

prefix = None[source]
render(template_name=None, context=None, renderer=None)[source]
property template_name[source]
template_name_div = 'django/forms/div.html'[source]
template_name_label = 'django/forms/label.html'[source]
template_name_p = 'django/forms/p.html'[source]
template_name_table = 'django/forms/table.html'[source]
template_name_ul = 'django/forms/ul.html'[source]
use_required_attribute = True[source]
visible_fields()[source]

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

Custom Model Form

class integreat_cms.cms.forms.custom_model_form.CustomModelForm(**kwargs: Any)[source]

Bases: ModelForm

Form for populating all text widgets of a ModelForm with the default placeholder “Enter … here”. Use this form as base class instead of django.forms.ModelForm.

Form fields:

Parameters:

kwargs (Any)

__init__(**kwargs: Any) None[source]

Initialize placeholder model form

Parameters:

**kwargs (Any) – The supplied keyword arguments

Raises:

TypeError – If form is instantiated directly without an inheriting subclass

Return type:

None

add_error(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.

add_error_messages(request: HttpRequest) None[source]

This function accepts the current request and adds the form’s error messages to the message queue of django.contrib.messages.

Parameters:

request (HttpRequest) – The current request submitting the form

Return type:

None

add_initial_prefix(field_name)[source]

Add an ‘initial’ prefix for checking dynamic initial values.

add_prefix(field_name)[source]

Return the field name with a prefix appended, if this Form has a prefix set.

Subclasses may wish to override.

as_div()[source]

Render as <div> elements.

as_p()[source]

Render as <p> elements.

as_table()[source]

Render as <tr> elements excluding the surrounding <table> tag.

as_ul()[source]

Render as <li> elements excluding the surrounding <ul> tag.

changed_data[source]
clean() dict[str, Any][source]

This method extends the default clean()-method of the base ModelForm to provide debug logging

Returns:

The cleaned data (see Overriding the clean() method)

Return type:

dict[str, Any]

default_renderer = None[source]
property errors[source]

Return an ErrorDict for the data provided for the form.

field_order = None[source]
full_clean()[source]

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

get_context()[source]
get_error_messages() list[dict[str, str]][source]

Return all error messages of this form and append labels to field-errors

Returns:

The errors of this form

Return type:

list[dict[str, str]]

get_initial_for_field(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.

has_changed()[source]

Return True if data differs from initial.

has_error(field, code=None)[source]
hidden_fields()[source]

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

is_multipart()[source]

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

is_valid()[source]

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

property media[source]

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

non_field_errors()[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.

order_fields(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.

prefix = None[source]
render(template_name=None, context=None, renderer=None)[source]
save(commit: bool = True) Any[source]

This method extends the default save()-method of the base ModelForm to provide debug logging

Parameters:

commit (bool) – Whether or not the changes should be written to the database

Returns:

The saved object returned by The save() method

Return type:

Any

property template_name[source]
template_name_div = 'django/forms/div.html'[source]
template_name_label = 'django/forms/label.html'[source]
template_name_p = 'django/forms/p.html'[source]
template_name_table = 'django/forms/table.html'[source]
template_name_ul = 'django/forms/ul.html'[source]
use_required_attribute = True[source]
validate_unique()[source]

Call the instance’s validate_unique() method and update the form’s validation errors if any were raised.

visible_fields()[source]

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

Custom Tree Node Form

class integreat_cms.cms.forms.custom_tree_node_form.CustomTreeNodeForm(**kwargs: Any)[source]

Bases: MoveNodeForm

Form for creating and modifying tree node objects

Form fields:

Parameters:

kwargs (Any)

__init__(**kwargs: Any) None[source]

Initialize custom tree node form

Parameters:

**kwargs (Any) – The supplied keyword arguments

Return type:

None

add_error(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.

add_initial_prefix(field_name)[source]

Add an ‘initial’ prefix for checking dynamic initial values.

add_prefix(field_name)[source]

Return the field name with a prefix appended, if this Form has a prefix set.

Subclasses may wish to override.

classmethod add_subtree(for_node, node, options)[source]

Recursively build options tree.

as_div()[source]

Render as <div> elements.

as_p()[source]

Render as <p> elements.

as_table()[source]

Render as <tr> elements excluding the surrounding <table> tag.

as_ul()[source]

Render as <li> elements excluding the surrounding <ul> tag.

changed_data[source]
clean()[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__’.

default_renderer = None[source]
property errors[source]

Return an ErrorDict for the data provided for the form.

field_order = None[source]
full_clean()[source]

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

get_context()[source]
get_initial_for_field(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.

has_changed()[source]

Return True if data differs from initial.

has_error(field, code=None)[source]
hidden_fields()[source]

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

static is_loop_safe(for_node, possible_parent)[source]
is_multipart()[source]

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

is_valid()[source]

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

property media[source]

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

classmethod mk_dropdown_tree(model: ModelBase, for_node: None | LanguageTreeNode | Page = None) list[source]

Creates a tree-like list of choices. Overwrites the parent method because the field is hidden anyway and additional queries to render the node titles should be avoided.

Parameters:
  • model (ModelBase) – ~integreat_cms.cms.models.abstract_tree_node.AbstractTreeNode

  • for_node (None | (LanguageTreeNode | Page)) – The instance of this form

Returns:

A list of select options

Return type:

list

static mk_indent(level)[source]
non_field_errors()[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.

order_fields(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.

prefix = None[source]
render(template_name=None, context=None, renderer=None)[source]
save(commit=True)[source]

Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.

property template_name[source]
template_name_div = 'django/forms/div.html'[source]
template_name_label = 'django/forms/label.html'[source]
template_name_p = 'django/forms/p.html'[source]
template_name_table = 'django/forms/table.html'[source]
template_name_ul = 'django/forms/ul.html'[source]
use_required_attribute = True[source]
validate_unique()[source]

Call the instance’s validate_unique() method and update the form’s validation errors if any were raised.

visible_fields()[source]

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

Icon Widget

class integreat_cms.cms.forms.icon_widget.IconWidget(attrs=None)[source]

Bases: HiddenInput

A custom widget to render the icon field

__init__(attrs=None)[source]
build_attrs(base_attrs, extra_attrs=None)[source]

Build an attribute dictionary.

format_value(value)[source]

Return a value as it should appear when rendered in a template.

get_context(name: str, value: Any | None, attrs: dict[str, Any]) dict[str, dict[str, Any]][source]

This function gets the context of icon fields

Parameters:
  • name (str) – the supplied name

  • value (Any | None) – the supplied values

  • attrs (dict[str, Any]) – the supplied attrs

Returns:

context

Return type:

dict[str, dict[str, Any]]

id_for_label(id_)[source]

Return the HTML ID attribute of this Widget for use by a <label>, given the ID of the field. Return an empty string if no ID is available.

This hook is necessary because some widgets have multiple HTML elements and, thus, multiple IDs. In that case, this method should return an ID value that corresponds to the first ID in the widget’s tags.

input_type = 'hidden'[source]
property is_hidden[source]
is_localized = False[source]
is_required = False[source]
property media[source]
needs_multipart_form = False[source]
render(name, value, attrs=None, renderer=None)[source]

Render the widget as an HTML string.

subwidgets(name, value, attrs=None)[source]
supports_microseconds = True[source]
template_name = 'icon_widget.html'[source]

The template to use for this widget

use_fieldset = False[source]
use_required_attribute(initial)[source]
value_from_datadict(data, files, name)[source]

Given a dictionary of data and this widget’s name, return the value of this widget or None if it’s not provided.

value_omitted_from_data(data, files, name)[source]

Machine Translation Form

class integreat_cms.cms.forms.machine_translation_form.MachineTranslationForm(**kwargs: Any)[source]

Bases: CustomContentModelForm

Form for selecting target languages for machine translation of a content object. It should be used as base class for translation forms which enable machine translations.

Form fields:

Parameters:

kwargs (Any)

__init__(**kwargs: Any) None[source]

Initialize MT translation form. If request and language kwargs are missing, MTs are disabled.

Parameters:

**kwargs (Any) – The supplied keyword arguments

Return type:

None

add_error(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.

add_error_messages(request: HttpRequest) None[source]

This function accepts the current request and adds the form’s error messages to the message queue of django.contrib.messages.

Parameters:

request (HttpRequest) – The current request submitting the form

Return type:

None

add_initial_prefix(field_name)[source]

Add an ‘initial’ prefix for checking dynamic initial values.

add_prefix(field_name)[source]

Return the field name with a prefix appended, if this Form has a prefix set.

Subclasses may wish to override.

add_success_message(request: HttpRequest) None[source]

This adds a success message for a translation form. Requires the attributes “title”, “status” and “foreign_object” on the form instance.

Parameters:

request (HttpRequest) – The current request submitting the translation form

Return type:

None

as_div()[source]

Render as <div> elements.

as_p()[source]

Render as <p> elements.

as_table()[source]

Render as <tr> elements excluding the surrounding <table> tag.

as_ul()[source]

Render as <li> elements excluding the surrounding <ul> tag.

changed_data[source]
clean() dict[str, Any][source]

Validate form fields which depend on each other, see django.forms.Form.clean()

Returns:

The cleaned form data

Return type:

dict[str, Any]

clean_content() str[source]

Validate the content field (see Overriding the clean() method) and applies changes to any element to match the guidelines.

Raises:

ValidationError – When a heading 1 (<h1>) is used in the text content

Returns:

The valid content

Return type:

str

clean_slug() str[source]

Validate the slug field (see Overriding the clean() method)

Returns:

A unique slug based on the input value

Return type:

str

default_renderer = None[source]
property errors[source]

Return an ErrorDict for the data provided for the form.

field_order = None[source]
full_clean()[source]

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

get_context()[source]
get_error_messages() list[dict[str, str]][source]

Return all error messages of this form and append labels to field-errors

Returns:

The errors of this form

Return type:

list[dict[str, str]]

get_initial_for_field(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.

has_changed()[source]

Return True if data differs from initial.

has_error(field, code=None)[source]
hidden_fields()[source]

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

is_multipart()[source]

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

is_valid()[source]

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

property media[source]

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

mt_form_is_enabled() NS_NodeQuerySet[source]

Helper method to decide if this form should be shown, or if it should be hidden for the current language due to a lack of MT-compatible child language nodes

Returns:

Whether this form is enabled

Return type:

NS_NodeQuerySet

non_field_errors()[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.

order_fields(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.

prefix = None[source]
render(template_name=None, context=None, renderer=None)[source]
save(commit: bool = True, foreign_form_changed: bool = False)[source]

Create machine translations and save them to the database

Parameters:
  • commit (bool) – Whether or not the changes should be written to the database

  • foreign_form_changed (bool) – Whether or not the foreign form of this translation form was changed

Returns:

The saved content translation object

Return type:

EventTranslation | (PageTranslation | POITranslation)

property template_name[source]
template_name_div = 'django/forms/div.html'[source]
template_name_label = 'django/forms/label.html'[source]
template_name_p = 'django/forms/p.html'[source]
template_name_table = 'django/forms/table.html'[source]
template_name_ul = 'django/forms/ul.html'[source]
use_required_attribute = True[source]
validate_unique()[source]

Call the instance’s validate_unique() method and update the form’s validation errors if any were raised.

visible_fields()[source]

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

Object Search Form

class integreat_cms.cms.forms.object_search_form.ObjectSearchForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]

Bases: Form

Form for searching objects

Form fields:

__init__(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]
add_error(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.

add_initial_prefix(field_name)[source]

Add an ‘initial’ prefix for checking dynamic initial values.

add_prefix(field_name)[source]

Return the field name with a prefix appended, if this Form has a prefix set.

Subclasses may wish to override.

as_div()[source]

Render as <div> elements.

as_p()[source]

Render as <p> elements.

as_table()[source]

Render as <tr> elements excluding the surrounding <table> tag.

as_ul()[source]

Render as <li> elements excluding the surrounding <ul> tag.

changed_data[source]
clean()[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__’.

default_renderer = None[source]
property errors[source]

Return an ErrorDict for the data provided for the form.

field_order = None[source]
full_clean()[source]

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

get_context()[source]
get_initial_for_field(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.

has_changed()[source]

Return True if data differs from initial.

has_error(field, code=None)[source]
hidden_fields()[source]

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

is_multipart()[source]

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

is_valid()[source]

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

property media[source]

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

non_field_errors()[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.

order_fields(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.

prefix = None[source]
render(template_name=None, context=None, renderer=None)[source]
property template_name[source]
template_name_div = 'django/forms/div.html'[source]
template_name_label = 'django/forms/label.html'[source]
template_name_p = 'django/forms/p.html'[source]
template_name_table = 'django/forms/table.html'[source]
template_name_ul = 'django/forms/ul.html'[source]
use_required_attribute = True[source]
visible_fields()[source]

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